Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unix date script 1

Status
Not open for further replies.

jeanpaul

Technical User
Aug 13, 2000
20
SE
How do I get yesterdays date in YYYYMMDD?
 

Hi, jeanpaul!

I can create yesterdays date in YYYYMMDD with gawk. Please, try this gawk command:

gawk "BEGIN { print strftime("%Y%m%d",systime()) - 1 }"


Works?

KP.

 

rbobbitt and jeanpaul,

I appologize for double quotes.
Explanation: I use DOS and Win version of gawk (GNU), where I have to use double quotes.

Bye.

KP.
 
It works but the date field in incorrect
Example: At the command line I type:
$date
Sun Mar 25 13:24:12 EST 2001
When i run this program it prints out:
20010324 (March 24th 2001)
Is this my computer system time is incorrect or what?
 
Oh my fault...I didn't read the question clearly. It is yesterday date not today date. It is correct....sorry all.

BVT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top