- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- yesterday's date
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 06:58 AM
тАО04-05-2004 06:58 AM
Is there an easy way to get yesterday's date (yyyymmdd)with the date command?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 07:02 AM
тАО04-05-2004 07:02 AM
Re: yesterday's date
http://www.hpux.ws/merijn/caldj-2.3.sh
Perl
http://www.hpux.ws/merijn/caldj-2.2.pl
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 07:05 AM
тАО04-05-2004 07:05 AM
Re: yesterday's date
YESTERDAY=$(caljd.sh -s -y $(caljd.sh -p 1))
echo "Yesterday was ${YESTERDAY}"
Invoke as caljd.sh -u for full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 07:22 AM
тАО04-05-2004 07:22 AM
Re: yesterday's date
chop($day = `date \"+%d\"`);
chop($month = `date \"+%m\"`);
chop($year = `date \"+%y\"`);
$prevday = $day - 1;
if ($prevday == 0) #if first of month
{
if (($month==1) || ($month==3) || ($month==5) || ($month==7) || ($month==8) || ($month==10) || ($month==12))
{
$prevday = 31;
}
else
{
$prevday = 30;
if ($month == 2)
{
$prevday = 28;
}
}
}
if ($prevday =~ /^\d{1}$/) #format day to be 2 digits
{
$prevday = "0$prevday";
}
-Hazem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 07:57 AM
тАО04-05-2004 07:57 AM
Re: yesterday's date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 08:47 AM
тАО04-05-2004 08:47 AM
Re: yesterday's date
perl -e '$yesterday = localtime(time-24*60*60),print "$yesterday\n"'
perl -e '$yesterday = localtime(time-86400),print "$yesterday\n"'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 09:00 AM
тАО04-05-2004 09:00 AM
Re: yesterday's date
--8<---
How do I print Yesterday?
d3:/ 102 > echo 'Yesterday'
Yesterday
d3:/ 103 > perl -le 'print scalar localtime time - 86400'
Or use A.Clay Stephenson's date hammer, which can also be used for more complicated actions from the command line, as will using the modules Date::Calc or Date::Manip with Perl.
-->8---
my HP ITRC site pages can be found at
Singapore https://www.beepz.com/personal/merijn/#FAQ
Rotterdam http://www.cmve.net/~merijn/#FAQ
Seattle http://www.hpux.ws/merijn/#FAQ
And it also hosts caldj - both versions - in the last section of the page
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 10:56 AM
тАО04-05-2004 10:56 AM
Re: yesterday's date
If you download the date command from gnu coreutils the yesterday's date is very easy to obtain,
date --date yesterday +%F
you get the date in yyyy-mm-dd
or
date --date yesterday %Y%m%d
you get the date in yyyymmdd
I've tried with some tricky dates like:
date --date '01 march 2004 1 day ago'
and
date --date '01 march 2003 1 day ago'
and
date --date '01 Jan 2003 1 day ago'
and so on, the result is good.
You can download the date command from gnu coreutils from the software porting center:
http://hpux.cs.utah.edu/hppd/hpux/Gnu/coreutils-5.2.0/
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 10:59 AM
тАО04-05-2004 10:59 AM
Re: yesterday's date
I've made a mistake the sentence:
date --date yesterday %Y%m%d
must be
date --date yesterday +%Y%m%d
sorry
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 03:25 PM
тАО04-05-2004 03:25 PM
Re: yesterday's date
Look into this below link.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=222968
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2004 12:24 AM
тАО04-06-2004 12:24 AM
Re: yesterday's date
The link you gave me :
http://www.hpux.ws/merijn/caldj-2.3.sh
is not accessible. Is there another way to get the script?
Thanks very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2004 12:32 AM
тАО04-06-2004 12:32 AM
Re: yesterday's date
My HP ITRC site pages can be found at
Singapore https://www.beepz.com/personal/merijn/caldj-2.3.sh
Rotterdam http://www.cmve.net/~merijn/caldj-2.3.sh
Seattle http://www.hpux.ws/merijn/caldj-2.3.sh
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2004 01:06 AM
тАО04-06-2004 01:06 AM
SolutionAll links should work again in a few hours. cmve is correct again
Enjoy, Have FUN! H.Merijn [ don't forget about the etiquette and assign point to _all_ answers. 0 is better than not assigned ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2004 01:17 AM
тАО04-06-2004 01:17 AM
Re: yesterday's date
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2004 07:29 PM
тАО04-06-2004 07:29 PM
Re: yesterday's date
I have now corrected *all* misspelled references to caljd.sh, caljd.pl, caljd-2.3.sh, caljd-2.2.pl, and caljd-2.2.sh on my site
Most were spelt as caldj :(
Catherine, please do not Forget to assign points to _all_ posts. 0 (or no) points is OK, but don't leave them unassigned.
Enjoy, Have FUN! H.Merijn