- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Display Yesterday Date from HP-UX
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
Forums
Discussions
Discussions
Discussions
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
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-2002 12:48 AM
04-05-2002 12:48 AM
How can I display yesterday date from HP-UX command prompt ?
TQVM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 12:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 12:52 AM
04-05-2002 12:52 AM
Re: Display Yesterday Date from HP-UX
See thread http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x583e7b8d1de3d5118ff40090279cd0f9,00.html
Regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 01:03 AM
04-05-2002 01:03 AM
Re: Display Yesterday Date from HP-UX
You can use date format like:
$ date +%y/%d/%m
The thing is to get the previous day.
A rather lengthy solution would be:
month=`date +%m`
day=`date +%d`
year=`date +%Y
day=`expr $day - 1`
echo "$year/$day/$month"
Good Luck,
Rumagoso
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 01:13 AM
04-05-2002 01:13 AM
Re: Display Yesterday Date from HP-UX
echo `(export TZ=XYZ+24; date "+%x")`
Kurt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 01:14 AM
04-05-2002 01:14 AM
Re: Display Yesterday Date from HP-UX
l1:/u/usr/merijn 105 > perl -le '@d=localtime time-86400;$,="-";print$d[3],++$d[4],$d[5]+1900'
4-4-2002
l1:/u/usr/merijn 106 >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 03:37 AM
04-05-2002 03:37 AM
Re: Display Yesterday Date from HP-UX
cal;date
BB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 04:00 AM
04-05-2002 04:00 AM
Re: Display Yesterday Date from HP-UX
fdate -1 ( to know the yesterday date)
#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-05-2002 04:30 AM
04-05-2002 04:30 AM
Re: Display Yesterday Date from HP-UX
echo `(export TZ=XYZ+24; date "+%d/%m/%y")`
gives the date of yesterday in the format DD/MM/YY
Kurt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 04:50 AM
04-05-2002 04:50 AM
Re: Display Yesterday Date from HP-UX
The use of the following is commonly seen to compute yesterday's date:
# TZ=GMT+24 date +%m/%d/%y
Our European friends living around the Prime Meridian are the "lucky" ones who can use +-24 hours to exactly compute yesterday or tommorrow including the correct time.
If you look at the man pages for environ (5) you will note that offset is the value that must be added to local time to arrive at UTC (GMT). The offset takes the format hh[:mm[:ss]] where(hh)is any value from 0 through 23. The optional minutes (mm) and seconds (ss) fields are a value from 0 through 59. The hour field is required. If offset is preceded by a -, the time zone is east of the Prime Meridian. A + preceding offset indicates that the time
one is west of the Prime Meridian.
Notice, for example that while it is now 0749 hours on April 5 in the Eastern US, you cannot produce a date *and time* exactly 24-hours ago. To affect this, the computation would need to offset 29 hours (24+5), an invalid offset.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 04:57 AM
04-05-2002 04:57 AM
Re: Display Yesterday Date from HP-UX
Kurt: Why? Though this will work in the shell (as requested), it'll barf in the (t)csh:
a5:/pro/3gl/GNU/gcc-3.0.4 229 > echo `(export TZ=XYZ+24; date "+%d/%m/%y")`
export: Command not found.
05/04/02
a5:/pro/3gl/GNU/gcc-3.0.4 230 > echo `(env TZ=XYZ+24 date "+%d/%m/%y")`
04/04/02
a5:/pro/3gl/GNU/gcc-3.0.4 231 >
but with the slashes, it -s still unclear to any european *how* he/she should parse that date. To be unambiguous, use YYYYMMDD
If I see dates with slashes, I have to *think*. I don't like to think with dates. Dates are complicated enough. Use month names :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 10:56 AM
04-05-2002 10:56 AM
Re: Display Yesterday Date from HP-UX
Assalaamu Alaikkum,
Here is another perl one-liner that you could use:
print `perl -e '@T=localtime(time-86400);printf("%02d/%02d/%02d",$T[4]+1,$T[3],($T[5]+1900)%100)'`
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2002 02:57 AM
04-08-2002 02:57 AM
Re: Display Yesterday Date from HP-UX
TZ=PST-24 date +%D
bye
Gabriele