- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to find the date of yesterday?
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
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-09-2002 01:24 AM
тАО04-09-2002 01:24 AM
I am writing a shell script that required to find yesterday's date?
Taking into account of change of month, year and leap year, I have written a code of over 30 lines just to calculate the previous date.
Is there a better way by using just a few lines of code?
Regards
Siew Hoong
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 01:27 AM
тАО04-09-2002 01:27 AM
SolutionSee this thread from a few days ago !
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xc0afba808b46d611abda0090277a778c,00.html
Clemens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 01:29 AM
тАО04-09-2002 01:29 AM
Re: How to find the date of yesterday?
john.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xc0afba808b46d611abda0090277a778c,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 01:43 AM
тАО04-09-2002 01:43 AM
Re: How to find the date of yesterday?
I had read some of the threads, I think the fastest and easiest way is to play around with the timezone variable.
export TZ=
date
cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 01:48 AM
тАО04-09-2002 01:48 AM
Re: How to find the date of yesterday?
fdate -1 ( to know the yesterday date)
With this script you can find whatever date you need ( fdate -N )
#include
#include
main(argc, argv)
int argc;
char **argv;
{
time_t seconds;
struct tm *timeptr;
if(argc > 1)
{
seconds = time((long *)0) + atoi(argv[1])*24*60*60;
timeptr = localtime(&seconds);
fputs(asctime(timeptr), stdout);
exit(0);
}
else
exit(1);
}
Ciao,
Federico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 01:58 AM
тАО04-09-2002 01:58 AM
Re: How to find the date of yesterday?
Yesterday=`TZ=aaa24 date +%Y%m%d`
should work fine.
-raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2002 10:13 AM
тАО04-24-2002 10:13 AM
Re: How to find the date of yesterday?
$date
Wed Apr 24 14:12:17 EDT 2002
$date -d "yesterday"
Tue Apr 23 14:12:19 EDT 2002
$date -d "a year ago"
Tue Apr 24 11:12:24 EDT 2001
$date -d "3 weeks ago"
Wed Apr 3 14:12:36 EST 2002
It is available as part of the shell-utils package from:
http://hpux.cs.utah.edu/hppd/hpux/Gnu/sh_utils-2.0/
Or, you can get the source from:
http://www.gnu.org/software/shellutils/shellutils.html