- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Days between 2 dates
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
10-29-2003 10:28 AM
10-29-2003 10:28 AM
A colleague told me about this site. I have two dates, 11/26/99 and 03/05/02, for example. It there a UNIX utility to determine the number of days between these two dates? This should be so simple.
Thanks in advance for your help,
John Chaff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 10:41 AM
10-29-2003 10:41 AM
Re: Days between 2 dates
Convery both the dates to sec from 1970 using time() function and then substract them and divide them by 3600 you'll get hours and then further divide by 24 to convery into days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 10:45 AM
10-29-2003 10:45 AM
Re: Days between 2 dates
Try Clay Stephenson's caljd perl script - it is easy to use. usage details are provided within.
https://www.beepz.com/personal/merijn/caljd-2.2.pl
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 10:48 AM
10-29-2003 10:48 AM
Re: Days between 2 dates
caljd.sh
caljd.pl
http://www.hpux.ws/merijn/caldj-2.2.sh
http://www.hpux.ws/merijn/caljd-2.2.pl
These will do the trick. Well documented, easy to use.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 10:51 AM
10-29-2003 10:51 AM
Solution#!/usr/bin/sh
DT1="11/26/99"
DT2="03/05/02"
DIFF=$(( $(caljd.sh -c -C -S "/" ${D2}) - $(caljd.sh -c -C -S "/" ${D1}) ))
echo "Difference = ${DIFF} days."
You will need a recent version of caljd.sh because I added the -C option to interpret 2-digit years as recent years rather than 1st-century CE dates. I do assume that you meant 1999CE rather than 99CE. 99CE would give ctime() functions fits. Invoke as caljd.sh -u for full usage but this should be exactly what you want.
Attached is caljd.sh, Version 2.22.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 10:54 AM
10-29-2003 10:54 AM
Re: Days between 2 dates
Attached is caljd.pl, Version 2.22p.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 10:59 AM
10-29-2003 10:59 AM
Re: Days between 2 dates
THIS HERE:
DIFF=$(( $(caljd.sh -c -C -S "/" ${D2}) - $(caljd.sh -c -C -S "/" ${D1}) ))
SHOULD BE:
DIFF=$(( $(caljd.sh -c -C -S "/" ${DT2}) - $(caljd.sh -c -C -S "/" ${DT1}) ))
No points please, Clay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 02:35 AM
10-30-2003 02:35 AM
Re: Days between 2 dates
Thanks,
John Chaff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 02:46 AM
10-30-2003 02:46 AM
Re: Days between 2 dates
# cd /tmp
# nohup caljd.sh -u
Sending output to nohup.out
# lp nohup.out
Regards,
Robert-Jan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 03:08 AM
10-30-2003 03:08 AM
Re: Days between 2 dates
It's trivially easy, just redirect stderr (file descriptor 2) onto stdout (fdes 1), viz:
caljd.sh -u 2>&1 | lp
OR
caljd.sh -u 2>&1 | more
That should fix you, Clay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 07:53 AM
10-30-2003 07:53 AM