Need help in finding in date difference

Hi,

My date is coming as

STARTDATE=Sun Jul 15 00:34:23 2012
ENDDATE=Sun Jul 15 00:50:04 2012

I want difference between these two dates,anyone's helps will be appriciated.

Thanks
Prasoon

With GNU tools:

STARTDATE="Sun Jul 15 00:34:23 2012"
ENDDATE="Sun Jul 15 00:50:04 2012"

rsd=$( date -d "$STARTDATE" +%s )  # raw start date
red=$( date -d "$ENDDATE" +%s )   # raw end date

echo "difference: $(( red - rsd )) seconds"

Convert each date to seconds since the epoch and subtract.

If you don't have GNU date, it would help to know what system you are using.

1 Like

@prasson_ibm
Just re-read the history of your posts and not managed to deduce what precise Operating System (an unknown vintage of IBM AIX?), or what Shell you use, or whether you have a modern version of Perl installed.

You posted a question nearly a year ago about date arithmetic which petered out because there was insufficient base information for anybody to post a solution to match your evolving requirement (only last post mentions the expected output format).

In the custom of this forum, please post the base information about your computer software, some representative sample input data which contains the date data, an explanation of the process, and the expected matching sample output data. Please mention the volume of data which needs to be processed and quote real numbers (i.e. not words like "huge").

Please do find out whether you have the BSD variant of the date command installed, and whether you have Perl installed (what version?), and whether you have ksh93 installed (unlikely with AIX but not impossible).

Hi,

I am working on windows env where MKSToolkit is installed.