Day before yesterday's date

Hello All,

I am writing a script in Sun Solaris
I want the date for "day before yesterday", i got the yesterday's date by this command

TZ=GMT+24 date +%b" "%d

.
Please suggest me some code to get the date for day before yesterday

 
$ DAY_BEFORE_YEST=`TZ="GMT+48" date +'%m/%d/%Y'`
$ echo $DAY_BEFORE_YEST
12/18/2012
 
1 Like
perl -le 'print scalar localtime (time() - 48*60*60);' |awk '{print $2 ,$3}'
1 Like

Thank You ningy and itkamaraj, It worked :b:

i just use Date command.

date +%Y%m%d -d '2 days ago'

you could even use your text

date +%Y%m%d -d 'day before yesterday'

(i just asked a question similar in the last week :wink: )

And in your question "in the last week" you were using CentOS, not Solaris :wink:

Useful information:
Perderabo's day/date arithmetic functions

And this was run on Solaris 10. I have Solaris 9 & 10, redhat and centos system (i don't do windows).

The 2 days ago option worked on each, though i do admit the day before yesterday wasn't liked on the all the systems so i should have left it out.