Re: Command-line-interface (CLI) calculator to work out the difference between 2 dates
On Sun, Aug 24, 2008 at 11:25:31AM -0500, Ron Johnson wrote:
> On 08/24/08 10:54, Edward J. Shornock wrote:
>> While I'm sure someone else will provide a much better way, I've used
>> something like
>> $ echo $(date -d 20080824 +%j) - $(date -d 20080724 +%j) | bc
> That a good idea. I never knew date(1) could do that. The problem,
> though, is that it doesn't span years.
> $ echo $(date -d 20090824 +%j) - $(date -d 20080724 +%j) | bc
> Use delta from epoch, instead.
> $ echo $[$(date -d 20090824 +%s) - $(date -d 20080724 +%s)]/86400|bc
Why pipe it to bc? Keep it in the shell:
$ echo $[$[$(date -d 20090824 +%s) - $(date -d 20080724 +%s)] / 86400]
"Curiosity is the very basis of education and if you tell me that curiosity
killed the cat, I say only the cat died nobly."
-- Arnold Edinborough
Rick Pasotto email@example.com http://www.niof.net