- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Days between, awk?
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
Forums
Discussions
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
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
07-01-2002 01:58 PM
07-01-2002 01:58 PM
Anybody know of an easy way to count the number of days between two dates like 7/1/2002 and 6/1/2001? I searched the forums and A. Clay's caljd.sh but it wants separate variables for month, day, and year. I was hoping someone already had an awk program to split the dates apart. Awk is not one of my strongpoints.
Thanks in advance,
Neil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 02:02 PM
07-01-2002 02:02 PM
Solutionhttp://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x1fb33a7b3682d611abdb0090277a778c,00.html
This one allows you to specify a date as one string. Hopefully this'll help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 02:09 PM
07-01-2002 02:09 PM
Re: Days between, awk?
Patrick pointed you to the latest version, 2.1, which will do this internally. If you had asked this a couple of weeks ago the answer would have been a simple awk script but due to a 'customer' request; your all set. Unfortunately your usage to not make my examples list. I might add it later after I see a few more typical date questions.
This should fix you, if and only if, you use caljd.sh (or caljd.pl) version 2.1.
---------------------------------------
D1="7/1/2002"
D2="6/1/2001"
DIFF=$(( $(caljd.sh -S "/" -c ${D1} - $(caljd.sh -S "/" -c ${D2}) ))
echo "Days = ${DIFF}"
If I counted those pesky paren's correctly, that shoulf fix you.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 02:15 PM
07-01-2002 02:15 PM
Re: Days between, awk?
The line:
DIFF=$(( $(caljd.sh -S "/" -c ${D1} - $(caljd.sh -S "/" -c ${D2}) ))
Should be (I think):
DIFF=$(( $(caljd.sh -S "/" -c ${D1}) - $(caljd.sh -S "/" -c ${D2}) ))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 02:18 PM
07-01-2002 02:18 PM
Re: Days between, awk?
I just realized that your question was a bit ambiguous in that 7/1/2002 might be July 1, 2002 or it might be 7 January, 2002 especially if you was one of them folks what lives way over yonder. If that is the case then you need to add the -e (European) option to both caljd.sh calls.
Regards and no more points for this, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 02:21 PM
07-01-2002 02:21 PM
Re: Days between, awk?
Patrick is indeed correct. My advanced one-finger hunt-and-peck method has failed me once again. That there boy is smarter than I am.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 02:25 PM
07-01-2002 02:25 PM
Re: Days between, awk?
(No points for this)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 02:26 PM
07-01-2002 02:26 PM
Re: Days between, awk?
Clay, I had your earlier version but this date "sledgehammer" is great. I especially liked your examples section.
Thanks again to both of you,
Neil