how to get the days from a certain date?
Hi, guys
Do you have any idea of calculating days' distance? for instance, Code:
( 2010-9-16 ) minus (2010-9-1) = 16 days Could you kindly help? Thanks, Milo |
This should get you started:
Code:
declare -i $day_of_the_year=$(date -d 'yyyy-mm-dd' +%j) |
Quote:
Sorry, May be I am missing something on this problem: Your solution works for current year. But, this calculation is not always in current year, Code:
[root@www ~]# declare -i day_of_the_year=$(date -d '1970-01-01' +%j) Thanks, br, milo |
If you only want to use shell script (not Perl), then the following should work. Just pass the two dates on the command line.
Code:
./script.sh 2010-12-9 2010-10-3 Code:
#!/bin/sh |
Quote:
|
All times are GMT -5. The time now is 02:57 PM. |