Day before yesterday's date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Day before yesterday's date
# 1  
Old 12-20-2012
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
Code:
TZ=GMT+24 date +%b" "%d

.
Please suggest me some code to get the date for day before yesterday
# 2  
Old 12-20-2012
Code:
 
$ DAY_BEFORE_YEST=`TZ="GMT+48" date +'%m/%d/%Y'`
$ echo $DAY_BEFORE_YEST
12/18/2012

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 12-20-2012
Code:
perl -le 'print scalar localtime (time() - 48*60*60);' |awk '{print $2 ,$3}'

This User Gave Thanks to ningy For This Post:
# 4  
Old 12-20-2012
Thank You ningy and itkamaraj, It worked Smilie
# 5  
Old 12-20-2012
i just use Date command.

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

you could even use your text
Code:
date +%Y%m%d -d 'day before yesterday'

(i just asked a question similar in the last week Smilie )
# 6  
Old 12-20-2012
Quote:
Originally Posted by oly_r
i just use Date command.

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

you could even use your text
Code:
date +%Y%m%d -d 'day before yesterday'

(i just asked a question similar in the last week Smilie )
And in your question "in the last week" you were using CentOS, not Solaris Smilie

Useful information:
Perderabo's day/date arithmetic functions
# 7  
Old 12-20-2012
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

hi all, How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

2. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

3. Shell Programming and Scripting

How to get tomorrow,yesterday date from date Command

Hi I want to get tomorrow and yesterday date from date command. My shell is KSH and server is AIX. I tried several options, but unable to do. Please help on this. Regards Rajesh (5 Replies)
Discussion started by: rajeshmepco
5 Replies

4. Shell Programming and Scripting

[Solved] Replace yesterday date with today's date except from the first line

Hello, I have a file like this: 2012112920121130 12345620121130msABowwiqiq 34477420121129amABamauee e7748420121130ehABeheheei in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

5. Shell Programming and Scripting

Need help in Shell Script comparing todays date with Yesterday date from Sysdate

Hi, I want to compare today's date(DDMMYYYY) with yesterday(DDMMYYYY) from system date,if (today month = yesterday month) then execute alter query else do nothing. The above requirement i want in Shell script(KSH)... Can any one please help me? Double post, continued here. (0 Replies)
Discussion started by: kumarmsk1331
0 Replies

6. Shell Programming and Scripting

Removing day before yesterday's date

Hi i am having a backup folder wherein i will be having the files ftp ed to remote server, i need to keep only the data of last two days and remove the old log files. how can i achieve this ? i have tried... #!/bin/bash D=`date +'%d'` oldday=`expr $D - 2` rm /sent/data-$oldday* echo... (8 Replies)
Discussion started by: aemunathan
8 Replies

7. Shell Programming and Scripting

Get yesterday's date in year-month-day format?

Dear All, Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report. to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies

8. Shell Programming and Scripting

Compare date from db2 table to yesterday's Unix system date

I am currently running the following Korn shell script which works fine: #!/usr/bin/ksh count=`db2 -x "select count(*) from schema.tablename"` echo "count" I would like to add a "where" clause to the 2nd line that would allow me to get a record count of all the records from schema.tablename... (9 Replies)
Discussion started by: sasaliasim
9 Replies

9. Shell Programming and Scripting

Yesterday's Day of week

I need o get yesterday's day of week but im not exactly sure. the actual name is what i want. I can do it with numbers but im not sure with words. (3 Replies)
Discussion started by: rcunn87
3 Replies
Login or Register to Ask a Question