Is there any tool in Solaris UNIX (so no GNU tool available) to subtract dates? I know that in Linux we have gawk
that can subtract one date from another. But in Solaris the maximum we have is nawk
(improved awk
) which cannot perform date calculations. Also I cannot use perl.
Is there any way to do date calculations like 20100909 - 20001010
?
UPDATE: Is bc
able to perform dates calculations?
Best Answer
Here is an awk script I just wrote up, should work with an POSIX awk. You'll have to try the Solaris version; remember that there are two versions of Awk on Solaris as well, one in /bin and one in /usr/xpg4/bin/awk (which is nawk, I believe).
Pass a YYYYmmdd date string through and it will be converted to number of seconds since the Epoch (with a bit of give for being on day boundaries). Then you will be able to subtract the two.