- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: date string comparison ?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 07:20 AM
12-19-2002 07:20 AM
date string comparison ?
I have two strings with date/times in them
eg. "12:25 12:00" and "12:26 11:00"
is there some form of unix command that will compare two date strings (not necessarily in above format) and give the time between them ?
Any help appreciated
Thanks
Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 07:22 AM
12-19-2002 07:22 AM
Re: date string comparison ?
Search the forums (using the search button on the top left of this page) for Clay's caljd.sh script. It's a wonderful thing and just what you're looking for.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 07:25 AM
12-19-2002 07:25 AM
Re: date string comparison ?
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 08:49 AM
12-19-2002 08:49 AM
Re: date string comparison ?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 08:53 AM
12-19-2002 08:53 AM
Re: date string comparison ?
and give answer in minutes !!
pushing my luck ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 10:23 AM
12-19-2002 10:23 AM
Re: date string comparison ?
if nothing else works, you can try the attached, rather slow script. It can return the number of seconds elapsed since 00:00 Jan 1 of a specified year - and a specified date/time. The script takes seven parameters of which the first is the year on whose midnight Jan 1 the count starts. The remaining six parameters are the year, month, day, hour, minute, and seconds to count up to.
It may sound obscure, an example: show the number of seconds since 00:00 Jan 1 of 2002 and December 25 12:25 same year:
# ./return_seconds.sh 2002 2002 12 25 12 00 00
30974400
Another example:
# ./return_seconds.sh 2002 2002 12 26 11 00 00
31057200
The difference in seconds:
# echo 31057200 - 30974400|bc
82800
And turned into minutes:
# echo 82800 \/ 60|bc
1380
Is that what you want?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2002 04:23 PM
12-20-2002 04:23 PM
Re: date string comparison ?
You can do the math on the seconds since epoch then convert back to local time.