- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Continuous day count
Operating System - OpenVMS
1753529
Members
4908
Online
108795
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО02-10-2011 09:51 PM
тАО02-10-2011 09:51 PM
Re: Continuous day count
>> I expected 8340 not 8338. Below is me running it:
A little late, but you are correct.
I managed to paste a wrong version of the
code.
The leapyear test should be done before the increment. Sorry.
That makes it 8339.
It becomes 8340 if you want to count inclusive of start and end date for a duration.
The reason why this reply is so late is because I wanted to point out that it was not
my intention to edit the file for a specific start, but to just use an early enough date to handle start and end.
I used 17_NOV_1858 because that's the OpenVMS limit.
Next I tried 1-JAN-1900 because that's the EXCEL base date for use with DATEVALUE.
Handy for testing I thought....
Except that those amateurs at Microsoft got it wrong!
They have year 1900 as a Leap Year! Argh!
So I wasted a good bit of time getting confused by that + my own calculation order problem.
Excel::
text datevalue
1/1/1900 1
2/28/1900 59
3/1/1900 61
2/8/2011 40582
4/10/1988 32243
8339
I guess a handy base date is 1/1/1970.
That's the Unix base date ( UTC )
The code below gives:
$ @DAY_SINCE_1_JAN_1970.COM 11-feb-2011:04:40
11-FEB-2011:04:40 is 15016 days since 1_jan_1970. Unix Epoch Seconds: 1297399200
Confirmed with:
$ perl -e "print time"
1297399257
and also
$ @DAY_SINCE_1_JAN_1970.COM 1-jan-1970
1-JAN-1970 is 0 days since 1_jan_1970. Unix Epoch Seconds: 0
$ @DAY_SINCE_1_JAN_1970.COM 2-jan-1970
2-JAN-1970 is 1 days since 1_jan_1970. Unix Epoch Seconds: 86400
$ type DAY_SINCE_1_JAN_1970.COM
$
$ target = 123 ! This integer will become a string if Convert time works
$ target = F$CVT(P1,"ABSOLUTE","DATE")
$ IF F$TYPE(target) .NES. "STRING" THEN EXIT 16
$ year = 1969
$ days = -365
$ target_year = 'F$CVT( target,,"YEAR")
$
$year_loop:
$ year = year + 1
$ IF F$CVTIME("1-MAR-''year' -1-",,"DAY") THEN days = days + 1
$ days = days + 365
$ IF year.LT.target_year THEN GOTO year_loop
$
$ date = "1-JAN-''year'"
$day_loop:
$ IF date .EQS.target THEN GOTO done
$ date = F$CVT("''date' +1-","ABSOLUTE","DATE")
$ days = days + 1
$ goto day_loop
$
$ done:
$ seconds = days*86400 + 3600*F$CVT(p1,,"HOUR") + 60*F$CVT(p1,,"MINUTE") + F$CVT(p1,,"SECOND")
$ write sys$output p1, " is ", days, " days since 1_jan_1970. Unix Epoch Seconds: ", seconds
Cheers,
Hein
btw... the website I referred to reports:
http://www.convertunits.com/dates/from/Apr+10,+1988/to/Feb+8,+2011
"The total number of days between Sunday, April 10th, 1988 and Tuesday, February 8th, 2011 is 8,339 days.
This is equal to exactly 22 years, 9 months, and 29 days.
This does not include the end date, so it's accurate if you're measuring your age in days, or the total days between the start and end date. But if you want the duration of an event that includes both the starting date and the ending date, then it would actually be 8,340 days.
The total time span from 1988-04-10 to 2011-02-08 is 200,136 hours.
This is equivalent to 12,008,160 minutes.
You can also convert 8,339 days to 720,489,600 seconds."
Hein
A little late, but you are correct.
I managed to paste a wrong version of the
code.
The leapyear test should be done before the increment. Sorry.
That makes it 8339.
It becomes 8340 if you want to count inclusive of start and end date for a duration.
The reason why this reply is so late is because I wanted to point out that it was not
my intention to edit the file for a specific start, but to just use an early enough date to handle start and end.
I used 17_NOV_1858 because that's the OpenVMS limit.
Next I tried 1-JAN-1900 because that's the EXCEL base date for use with DATEVALUE.
Handy for testing I thought....
Except that those amateurs at Microsoft got it wrong!
They have year 1900 as a Leap Year! Argh!
So I wasted a good bit of time getting confused by that + my own calculation order problem.
Excel::
text datevalue
1/1/1900 1
2/28/1900 59
3/1/1900 61
2/8/2011 40582
4/10/1988 32243
8339
I guess a handy base date is 1/1/1970.
That's the Unix base date ( UTC )
The code below gives:
$ @DAY_SINCE_1_JAN_1970.COM 11-feb-2011:04:40
11-FEB-2011:04:40 is 15016 days since 1_jan_1970. Unix Epoch Seconds: 1297399200
Confirmed with:
$ perl -e "print time"
1297399257
and also
$ @DAY_SINCE_1_JAN_1970.COM 1-jan-1970
1-JAN-1970 is 0 days since 1_jan_1970. Unix Epoch Seconds: 0
$ @DAY_SINCE_1_JAN_1970.COM 2-jan-1970
2-JAN-1970 is 1 days since 1_jan_1970. Unix Epoch Seconds: 86400
$ type DAY_SINCE_1_JAN_1970.COM
$
$ target = 123 ! This integer will become a string if Convert time works
$ target = F$CVT(P1,"ABSOLUTE","DATE")
$ IF F$TYPE(target) .NES. "STRING" THEN EXIT 16
$ year = 1969
$ days = -365
$ target_year = 'F$CVT( target,,"YEAR")
$
$year_loop:
$ year = year + 1
$ IF F$CVTIME("1-MAR-''year' -1-",,"DAY") THEN days = days + 1
$ days = days + 365
$ IF year.LT.target_year THEN GOTO year_loop
$
$ date = "1-JAN-''year'"
$day_loop:
$ IF date .EQS.target THEN GOTO done
$ date = F$CVT("''date' +1-","ABSOLUTE","DATE")
$ days = days + 1
$ goto day_loop
$
$ done:
$ seconds = days*86400 + 3600*F$CVT(p1,,"HOUR") + 60*F$CVT(p1,,"MINUTE") + F$CVT(p1,,"SECOND")
$ write sys$output p1, " is ", days, " days since 1_jan_1970. Unix Epoch Seconds: ", seconds
Cheers,
Hein
btw... the website I referred to reports:
http://www.convertunits.com/dates/from/Apr+10,+1988/to/Feb+8,+2011
"The total number of days between Sunday, April 10th, 1988 and Tuesday, February 8th, 2011 is 8,339 days.
This is equal to exactly 22 years, 9 months, and 29 days.
This does not include the end date, so it's accurate if you're measuring your age in days, or the total days between the start and end date. But if you want the duration of an event that includes both the starting date and the ending date, then it would actually be 8,340 days.
The total time span from 1988-04-10 to 2011-02-08 is 200,136 hours.
This is equivalent to 12,008,160 minutes.
You can also convert 8,339 days to 720,489,600 seconds."
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 07:49 AM
тАО02-23-2011 07:49 AM
Re: Continuous day count
Thanks guys for all your help. It works perfectly.
Niall
Niall
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2011 02:12 AM
тАО02-24-2011 02:12 AM
Re: Continuous day count
Re. Hein,
"Except that those amateurs at Microsoft got it wrong!"
They claim it was Lotus who got it wrong:
http://support.microsoft.com/kb/214326
:-)
Oswald
"Except that those amateurs at Microsoft got it wrong!"
They claim it was Lotus who got it wrong:
http://support.microsoft.com/kb/214326
:-)
Oswald
- « Previous
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP