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 04:07 PM.. Reason: title fixed
Sponsored Links
    #2  
Old 06-26-2012
47shailesh 47shailesh is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 21 October 2014, 12:11 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: 3 December 2014, 7:08 AM EST
Location: Mumbai, India
Posts: 1,615
Thanks: 125
Thanked 184 Times in 178 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: 16 December 2014, 3:00 PM EST
Location: France
Posts: 318
Thanks: 19
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 04:07 PM..
Sponsored Links
    #6  
Old 06-26-2012
shamrock shamrock is offline Forum Advisor  
Registered User
 
Join Date: Oct 2007
Last Activity: 15 December 2014, 12:20 PM EST
Location: USA
Posts: 1,547
Thanks: 25
Thanked 149 Times in 141 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 07: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 05:49 PM
yesterday's date sandy1028 Shell Programming and Scripting 1 07-19-2010 04:01 AM
yesterday's date gratus Shell Programming and Scripting 2 02-19-2009 06:52 PM
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 9 12-01-2008 11:37 PM
yesterday date month/date skully Shell Programming and Scripting 5 06-24-2008 06:51 AM



All times are GMT -4. The time now is 01:55 PM.