Get yesterdays date given todays date


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Get yesterdays date given todays date
# 1  
Old 07-11-2008
Get yesterdays date given todays date

Hi Guys.

I am very new to UNIX.
I need to get yesterdays and tommorows date given todays date.
Which command and syntax do i use in basic UNIX shell.

Thanks.
# 2  
Old 07-11-2008
How depends on which shell and which specific operating system version you are using.

If you are using a GNU/Linux OS and bash then the date -d option is probablly the way to go.
Quote:
-d, --date=STRING
display time described by STRING, not 'now'
Look in the FAQ on Date Arithmetic on this forum for further information

If you are using something like ksh93 date arithmetic is built in
Code:
$ date
Fri Jul 11 05:21:56 EDT 2008
$ printf "%T\n" "yesterday"
Thu Jul 10 00:00:00 EDT 2008
$ printf "%T\n" "tomorrow"
Sat Jul 12 00:00:00 EDT 2008
$

# 3  
Old 07-11-2008
Hi Thanks for the response.

My script is as follows

#!/bin/sh

isql -U$2 -S$5 -w 200 -o/u/ap/summary << xxx
$3
use $4
go
selec *
from table where label in ($1)
and flag=0 and exercise( "E") and deal_date between "$6" and "$7"

go
xxx

$6 and $7 are the values for yesterday and tommorow
and i want them to be calculated from todays date before they are used by the script.

Thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 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

Get yesterdays Date for Input Date

Hi, I have been trying to get the yesterdays date for the Input date I pass. I know how to do for the current timestamp but how to do for the input date. Is there any way I can convert to epoch time and do manipulations and back to human readable date? Please help Thanks ... (1 Reply)
Discussion started by: abhi1988sri
1 Replies

3. Shell Programming and Scripting

How to list todays and yesterdays .rej files from a directory?

I am trying to display todays and yesterdays .rej files from a directory. ls -lrt *.rej | grep 'Aug 12' ; ls -lrt *.rej | grep 'Aug 13' Which is working as above. But i want take 'Aug 12' and 'Aug 13' from a variable and the command should work everyday. I am able to get todays files by... (9 Replies)
Discussion started by: GopalKrishnaP
9 Replies

4. 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

5. Shell Programming and Scripting

how to get the yesterdays date?

Hi All, Can anybody help me to get the yesterdays date in perl script. My script is as below #!/bin/perl -w $yes=system("TZ=IST+24 date +%d-%m-%Y"); print "$yes\n"; script is writting the date but with 0 pls see the output below #!/bin/perl -w $yes=system("TZ=IST+24 date... (2 Replies)
Discussion started by: jam_prasanna
2 Replies

6. Linux

Comparing the file drop date with todays date

Daily one file will dropped into this directory. Directory: /opt/app/jt/drop File name: XXXX_<timestamp>.dat.gz I need to write a script which checks whether the file is dropped daily or not. Any idea in the script how can we compare timestamp of the file to today's date?? (3 Replies)
Discussion started by: Rajneel
3 Replies

7. UNIX for Dummies Questions & Answers

Need to pull Yesterdays Date...

I tried this and it works for the most part, but if the date is 20090301, it displays 20090300. YESTERDAY=$((`date +%Y%m%d` -1)) (2 Replies)
Discussion started by: cards0622
2 Replies

8. UNIX for Dummies Questions & Answers

How to get yesterdays julian date

Hi, Was using date +%Y%j to get current julian date. Can anyone let me know how can I get y'day's julin date. Thx Did check FAQ but couldn't find anything. Thanks. (3 Replies)
Discussion started by: er_ashu
3 Replies

9. Shell Programming and Scripting

yesterdays date

To get yesterays date, execute the command : TZ=aaa24 date +%Y%m%d Output format will be yyyymmdd (2 Replies)
Discussion started by: sujju1985
2 Replies

10. Shell Programming and Scripting

Korn Shell Script - Getting yesterdays date

I need to get yesterdays date in the format yyyymmdd I can get today's date simply enough - 20031112 Is there any way to substract 1 from this easily enough in korn shell script? It has to be korn shell and not perl (20 Replies)
Discussion started by: frustrated1
20 Replies
Login or Register to Ask a Question