Calculate date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calculate date
# 1  
Old 12-18-2011
Calculate date

Hello, i need calculate the day before in this format aammdd, for example if i have 110701 i need a script to return the value 110630.

I only know what with this comand "date %y%m%d" return the date system.

Sorry for my english, it is very bad, i know...

Thank you very much
Grettings!
# 2  
Old 12-18-2011
If you have gnu date, then try this
Code:
 
date -d "yesterday" %y%m%d

---------- Post updated at 09:05 AM ---------- Previous update was at 09:04 AM ----------

Or using perl

Code:
 
mydate=$(perl -e '@T=localtime(time-86400);printf("%02d%02d%02d",($T[5]+1900)%100,$T[4]+1,$T[3])' )
echo $mydate

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

How to calculate the quarter end date according to the current date in shell script?

Hi, My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies

2. Shell Programming and Scripting

Calculate Julian date of a given date

How to get Julian date (Three digit) of a given date (Not current date)? I do not have root privilege - so can not use date -d. Assume that we have three variables year, month and date. Thx (5 Replies)
Discussion started by: Soham
5 Replies

3. Shell Programming and Scripting

Calculate given date - 1 day

Hi Team, We have a requirement as follows. If a date 20141220 as parameter to the script, then the script has to return the output as 20141219. i.e given date - 1. The requirement is simple. But it should satisfy leap year, the months having 31 and 30 days, the date in which day light... (9 Replies)
Discussion started by: kmanivan82
9 Replies

4. Programming

Calculate the current date.

Give your an integer (e.g. 0x0076f676) representing the number of minutes elapsed since January 1, 1996. How to calculate the current date which format should be "year-month-day-hour-minutes" ? (3 Replies)
Discussion started by: qcmao
3 Replies

5. Shell Programming and Scripting

Calculate the yesterday date

How to calculate the yesterday date? I am using SunOS. i.e. todays date is 01/27/2010 and i have to find "01/26/2010 00:07:00 AM" this output. (3 Replies)
Discussion started by: anupdas
3 Replies

6. Solaris

Calculate the yesterday date

How to calculate the yesterday date? I am using SunOS. i.e. todays date is 01/27/2010 and i have to find "01/26/2010 00:07:00 AM" this output. (1 Reply)
Discussion started by: anupdas
1 Replies

7. Programming

Calculate time to some date

Hello! I need to find how many days, hours and minutes remain to some specific date and I wonder why the following program shows incorrect values, such as 4 days 23 hours etc to 14:00 this Saturday from 17:33 today... #include <stdio.h> #include <time.h> int main() { time_t elaps,... (4 Replies)
Discussion started by: Sapfeer
4 Replies

8. Shell Programming and Scripting

Calculate date by week

Hi there!, Is there anyone can help me on how to calculate the date by weekly in shell scripting. Suppose that i have a statistical reports in Monday, tuesday, ...... I want to add the count of statistics by weekly. Please tell me any type of command which help me out. Thanks, (2 Replies)
Discussion started by: thans_guban
2 Replies

9. Shell Programming and Scripting

calculate the date of next satureday of current date.

I want to calculate the date of next satureday of current date using shell script. Suppose, today is 27-feb-08 I want to get the date of next satureday, which means 01-mar-08, in the formate '' YYMMDD ". I do this in ksh.. Please tell me any type of command which help me out. Thanks in... (3 Replies)
Discussion started by: rinku
3 Replies

10. Shell Programming and Scripting

How can I use mathematic calculate in date?

Hi all, All I need to do is calculate the system date to my desire date. My case is everyday in my system , it will receive ftp file from another unix server. If I issued 'date' for today it will return this : -bash-3.00$ date +%Y%m%d 20070605 but the ftp file that receive everyday... (1 Reply)
Discussion started by: guitaroa47
1 Replies
Login or Register to Ask a Question