Computing.Net > Forums > Unix > difference in time

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

difference in time

Reply to Message Icon

Name: Venu
Date: April 27, 2005 at 01:06:15 Pacific
OS: HP Unix
CPU/Ram: 2Gig
Comment:

Hi Guru's,

Need you help write a script to findout the difference between two given time values

input ex: 155834 (hr,min,sec)

should be able to know that difference between 155834 and 181210 is > 2hrs

also how to detect if the day flips over means difference between 23:00 and 02:00

Thanks in advance

Cheers

Venu



Sponsored Link
Ads by Google

Response Number 1
Name: Luke Chi
Date: April 27, 2005 at 09:07:09 Pacific
Reply:

If you have Oracle installed:

SQL> select 86400 * (to_date(181210, 'hh24miss') - to_date(155834, 'hh24miss')) || ' Seconds' Diff from dual;

DIFF
------------
8016 Seconds

Obviously, you should have the timestamp including year, month, date in order to diff two timestamps:

SQL> select 86400 * (to_date('04/27/2005 005834', 'mm/dd/yyyy hh24miss') - to_date('04/26/2005 235834', 'mm/dd/yyyy hh24miss')) || ' Seconds' Diff from dual
SQL> /

DIFF
------------
3600 Seconds


Luke Chi


0

Response Number 2
Name: Luke Chi
Date: April 27, 2005 at 09:36:16 Pacific
Reply:

See:

"Are there any tools or scripts available that will take two timestamps and return elapsed time?"

http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0xe5d194f22a31d6118fff0090279cd0f9%2C00.html&admit=716493758+1114619533561+28353475

Luke Chi


0

Response Number 3
Name: ravi.kumar
Date: April 28, 2005 at 04:51:21 Pacific
Reply:

I haven't heard of any tool in HP-UX which gives time difference, but the tool "ntpdate" can be used to synchronize the time and date

Hello I am working extensively on SCM and Unix


0

Response Number 4
Name: Wolfbone
Date: April 28, 2005 at 14:48:57 Pacific
Reply:

Can I infer from this thread that HP-UX now ships with a shell incapable of integer arithmetic? ;-)


0

Response Number 5
Name: Venu
Date: May 3, 2005 at 22:13:33 Pacific
Reply:

Guys,

Thanks to all for your help. I think the HP ITRC Link is very usefull.

Cheers :)


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: difference in time

Difference in shells www.computing.net/answers/unix/difference-in-shells/2023.html

Time diff and date formatting prob www.computing.net/answers/unix/time-diff-and-date-formatting-prob/5065.html

Nested while loop www.computing.net/answers/unix/nested-while-loop/7684.html