![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Number of days between two distinct dates | radheymohan | UNIX for Advanced & Expert Users | 1 | 10-16-2007 08:39 AM |
| Find number of days and list out the dates in between | Raynon | Shell Programming and Scripting | 2 | 02-12-2007 08:52 PM |
| Difference between two dates in no of days ??? | csaha | Shell Programming and Scripting | 1 | 01-13-2006 06:44 AM |
| Difference between two dates... | rajus19 | Shell Programming and Scripting | 4 | 01-04-2006 04:53 AM |
| days elapsed between 2 dates | rkkiran | UNIX for Dummies Questions & Answers | 1 | 03-04-2002 12:45 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
try this to start - note you have to handle cross-years eg 2007 -> 2008
Code:
#!/bin/ksh
yday()
{
perl -e '
use POSIX qw(strftime);
$fmt = "%j"; # %j day of year 1 - 366
$mday = substr("$ARGV[0]", 8, 2);
$mon = substr("$ARGV[0]", 5 ,2);
$year = substr("$ARGV[0]", 0 ,4);
$weekday =
strftime($fmt, 0, 0, 0, $mday , $mon - 1, $year - 1900, -1, -1, -1);
print int $weekday;
' "$1"
}
today=$( yday 2008-03-10 )
oldat=$( yday 2008-01-03 )
ddiff=$(( $today - $oldat ))
echo "$ddiff"
|
|
||||
|
No I do not have Perl. This needs to be strictly in ksh.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|