How to display yesterday Date in AIX | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How to display yesterday Date in AIX

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-26-2012
aroragaurav.84 aroragaurav.84 is offline
Registered User
 
Join Date: Jun 2012
Last Activity: 6 November 2013, 4:34 PM EST
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
How to display yesterday Date in AIX

Hi,

I need help to display the yesterday date in format mentioned below:

Code:
2012-06-26-PM

I tried this but it displays current date:
Code:
`date +%Y-%m-%d-%p`


Last edited by radoulov; 06-26-2012 at 03:07 PM.. Reason: title fixed
Sponsored Links
    #2  
Old 06-26-2012
47shailesh 47shailesh is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 3 April 2014, 3:45 PM EDT
Location: NY
Posts: 203
Thanks: 13
Thanked 39 Times in 38 Posts
explore http://www.unix.com/answers-frequent...rithmetic.html
Sponsored Links
    #3  
Old 06-26-2012
clx clx is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 29 July 2014, 9:59 AM EDT
Location: Mumbai, India
Posts: 1,611
Thanks: 124
Thanked 182 Times in 176 Posts
For linux (GNU date) Try.

Code:
date --date '1 day ago' +%Y-%m-%d-%p

    #4  
Old 06-26-2012
tukuyomi tukuyomi is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 19 July 2014, 2:22 PM EDT
Location: France
Posts: 318
Thanks: 18
Thanked 81 Times in 76 Posts
Try this:
Code:
date +%Y-%m-%d-%p -d yesterday

Sponsored Links
    #5  
Old 06-26-2012
aroragaurav.84 aroragaurav.84 is offline
Registered User
 
Join Date: Jun 2012
Last Activity: 6 November 2013, 4:34 PM EST
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
I tried both but it gives me error:

Code:
date +%Y-%m-%d-%p -d yesterday
Error:date: 0551-402 Invalid character in date/time specification.
Usage: date [-u] [+"Field Descriptors"]


Code:
date --date '1 day ago' +%Y-%m-%d-%p
Error :date: Not a recognized flag: -
Usage: date [-u] [+"Field Descriptors"]


Last edited by radoulov; 06-26-2012 at 03:07 PM..
Sponsored Links
    #6  
Old 06-26-2012
shamrock shamrock is offline Forum Advisor  
Registered User
 
Join Date: Oct 2007
Last Activity: 23 June 2014, 12:35 PM EDT
Location: USA
Posts: 1,438
Thanks: 19
Thanked 136 Times in 128 Posts
What OS version are you on since the Linux date utility is very powerful and can display dates in many formats depending on the supplied options...
Sponsored Links
    #7  
Old 06-26-2012
aroragaurav.84 aroragaurav.84 is offline
Registered User
 
Join Date: Jun 2012
Last Activity: 6 November 2013, 4:34 PM EST
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
AIX saturn 3 5 00044BB7D600


Last edited by methyl; 06-26-2012 at 06:47 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help in Shell Script comparing todays date with Yesterday date from Sysdate kumarmsk1331 Shell Programming and Scripting 0 07-29-2011 04:49 PM
yesterday's date sandy1028 Shell Programming and Scripting 1 07-19-2010 03:01 AM
yesterday's date gratus Shell Programming and Scripting 2 02-19-2009 05:52 PM
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 9 12-01-2008 10:37 PM
yesterday date month/date skully Shell Programming and Scripting 5 06-24-2008 05:51 AM



All times are GMT -4. The time now is 01:00 AM.