date command

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers date command
# 1  
Old 07-30-2002
Computer date command

Using the date command

how do get yesterday's date??

date '+%b%e%Y'

July 30 2002

I need to get

July 29 2002

using the date command.


(p.s. sorry if it's a very obvious question)
# 2  
Old 07-30-2002
On at least some versions of UNIX, try the "v" flag:

date -v-24H
Marc Rochkind
# 3  
Old 07-30-2002
Thanks Marc

But my version of unix (sun solaris 2.6) dosen't have the -v option....
# 4  
Old 07-31-2002
Try this...It works but I'm not 100% sure how....(educated guess as to how going on here)

my_date=`TZ=a12 date +%Y%m%d%H` (H gives you the hour for verification)

The 12 indicates how many hours behind GMT you want the time to be...

I use GMT + 12 as my to get 24 hours before this I need to go from +12 to I use a12.

If your timezone is GMT then a24 would do it. If you're 8 hours behind GMT then a32 would be used (8 behind and 1 more day).

I think GMT is used here as the systems default timezone where one is not specified. Therefore if your system TZ is different - you'll need to work that out and adjust accordingly.
# 5  
Old 07-31-2002
See my datecalc script for one solution.
# 6  
Old 11-13-2002
Thanx everyone !!! That worked fine... also I had another script.

But just out of curiosity.... Isn't there any OS built system utility
e.g. something like "sysdate"

# 7  
Old 11-13-2002
Hammer & Screwdriver

I did it another way. Put a cron to run at 2315 daily to create a file with yesterday's date in whatever format u need. ANd read the file when u want. It is not the most elegant solution but it works for me!! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies

2. HP-UX

HP/UX command to pull file name/date based on date

HI, Can anyone tell me how to pull the date and file name separated by a space using the find command or any other command. I want to look through several directories and based on a date timeframe (find -mtime -7), output the file name (without the path) and the date(in format mmddyyyy) to a... (2 Replies)
Discussion started by: lnemitz
2 Replies

3. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

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

5. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. Shell Programming and Scripting

date command

Hi is it possible to give the date command like 24th July 2009 ive tried DATE=`date "+%d%m%Y" echo $DATE that only replies 2009 correctly. not sure how to display the month in full or if unix knows how to do i.e 2nd, 24th, 3rd (1 Reply)
Discussion started by: magnia
1 Replies

7. UNIX for Dummies Questions & Answers

date command

Hi All. I'm using date -a to 'drift' the time forward / backwards. The question is - how do I know when its finished 'drifting' ? On some systems I have another time reference I can use but not always. thanks (1 Reply)
Discussion started by: Mudshark
1 Replies

8. Shell Programming and Scripting

want to get previous date from date command in ksh

I want to get previous date from date command. I am using ksh shell. Exmp: today is 2008.09.04 I want the result : 2008.09.03 Please help. Thanks in advance. (4 Replies)
Discussion started by: rinku
4 Replies

9. Shell Programming and Scripting

date command help

Hi Todays date command said "last month is this month !" ;) $ cat /etc/redhat-release Red Hat Enterprise Linux ES release 4 (Nahant Update 3) $ date Thu Jul 31 14:21:21 JST 2008 $ date +%Y-%m 2008-07 $ date --date "last month" +%Y-%m 2008-07 $ date --date 'last month' Tue... (2 Replies)
Discussion started by: TK_2008
2 Replies

10. UNIX for Dummies Questions & Answers

Date Command

we're using HP-UX I need to change the year. What is the date command? Thanks (2 Replies)
Discussion started by: saldana
2 Replies
Login or Register to Ask a Question