How can I use mathematic calculate in date?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can I use mathematic calculate in date?
# 1  
Old 06-05-2007
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 is like this
birth_20070604.dat

see?
because this ftp file is less than today for 1 day.
I want to use this file to process to another job to execute this file .
So,I want to minus 1 day from system date that I got from 'date' function

BTW,I use solaris 10
when I use date -d
it said somethings like
illegal option -d

Thank you very much in advance


........................................................................................

Sorry Let me change my question
After I look backward through these forums
I found that they have some kind of this

DATE_STAMP=`TZ=CST+24 date +%Y%m%d`
echo $DATE_STAMP
20070604

So I can get a yesterday date already
but another problem is
A year format

I want to convert Christian era to Buddhist Era
That means
If I want to convert by mathematic
I need to +543 from current Christian era
eg. If want to change to Buddhist Era,I need to plus 543 to 2007
So, the Buddhist Era of this year is 2007+543 = 2550

Last edited by guitaroa47; 06-05-2007 at 07:21 AM..
# 2  
Old 06-05-2007
Code:
eval DATE_STAMP=$(TZ=CST+24 date +'$((%Y+543))%m%d')

Jean-Pierre.
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. Shell Programming and Scripting

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! (1 Reply)
Discussion started by: Xedrox
1 Replies

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

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

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

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

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

10. 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
Login or Register to Ask a Question