The Museum of HP Calculators

HP Articles Forum

[Return to the Index ]
[ Previous | Next ]

HP35s date functions: DOW, DDate, Date+, Gregorian to Julian conversions

Posted by David Persinger (US) on 16 Sept 2011, 2:21 p.m.

Background: As an engineer who manages projects, I find that I often had a need to determine the number of days between dates, what the date will be X number of days in the future, or which day of the week a certain date falls. These functions are common in the graphing and financial calculators but are missing in most scientifics. The attached program adds these functions to the HP35s.

The program uses routines published by the US Navy Observatory Astronomical Applications Department website.

The routine is valid for dates from 1801-2099.

Usage: Convert Gregorian to Julian Date: MM.DDYYYY XEQ I ENTER Example: 12.252010 XEQ I ENTER 2,455,556

Convert Julian to Gregorian Date: XXXXXXX XEQ J Enter Example: 24555556 XEQ J ENTER 12.252010

Day of Week:

This will return a numeric DOW to the stack with 0=Saturday, but I didnít want to have to figure the coded date in my head so I added many additional lines that display the day of week in text. You can choose to delete as you desire. The memory of the 35s is sufficient to leave these in without significant impact.

MM.DDYYYY XEQ M ENTER Example: 12.252010 XEQ H ENTER SAT (for 1 second) 0 (left on stack)

DDAYS: Calculates number of days between 2 dates.

MM.DDYYYY (first date) MM.DDYYYY (second date) XEQ L ENTER

Example: 1.012011 9.152011 XEQ L ENTER 257

DATE+: Computes date x days in future (or Ėx days in past).



1.012011 257 XEQ M ENTER 9.152011

Instructions: * indicates comment, do not try to enter as code.

I001 LBL I *MM.DDYYYY TO JULIAN I002 X<>Y I003 STO B I004 X<>Y I005 ENTER I006 IP I007 STO M I008 Rd I009 FP I010 100 I011 x I012 ENTER I013 IP I014 STO D I015 Rd I016 FP I017 10000 I018 x I019 STO Y I020 FN=K I021 SOLVE J I022 0.5 I023 + I024 RCL B I025 X<>Y I026 RTN J001 LBL J *JULIAN TO MM.DDYYYY J002 IP J003 68569 J004 + J005 STO L J006 4 J007 x J008 146097 J009 INT/ J010 STO N J011 RCL L J012 x<>y J013 146097 J014 x J015 3 J016 + J017 4 J018 INT/ J019 - J020 STO L J021 1 J022 + J023 4000 J024 x J025 1461001 J026 INT/ J027 STO I J028 RCL L J029 X<>Y J030 1461 J031 x J032 4 J033 INT/ J034 - J035 31 J036 + J037 STO L J038 80 J039 x J040 2447 J041 INT/ J042 STO J J043 RCL L J044 x<>y J045 2447 J046 x J047 80 J048 INT/ J049 - J050 STO K J051 RCL J J052 11 J053 INT/ J054 STO L J055 -12 J056 x J057 RCL J J058 2 J059 + J060 + J061 RCL N J062 49 J063 - J064 100 J065 x J066 RCL I J067 + J068 RCL L J069 + J070 STO I J071 1E6 J072 / J073 RCL K J074 100 J075 / J076 + J077 + J078 RTN K001 LBL K *Julian conversion equation K002 J=367xY-IDIV(7x(Y+IDIV(M+9,12)),4)+IDIV(275xM,9)+D+1721013.5 K003 RTN H001 LBL H *DAY OF WEEK H002 ENTER H003 CF10 H004 XEQ I001 H005 IP H006 5 H007 - H008 7 H009 RMDR H010 SF 10 H011 0 H012 x=y? H013 GTO H043 H014 CLx H015 1 H016 x=y? H017 GTO H048 H018 CLx H019 2 H020 x=y? H021 GTO H053 H022 CLx H023 3 H024 x=y? H025 GTO H058 H026 CLx H027 4 H028 x=y? H029 GTO H063 H030 CLx H031 5 H032 x=y? H033 GTO H068 H034 CLx H035 6 H036 x=y? H037 GTO H073 H038 EQN BAD DATA H039 PSE H040 CF10 H041 Rd H042 RTN H043 SAT H044 PSE H045 CF10 H046 Rd H047 RTN H048 SUN H049 PSE H050 CF10 H051 Rd H052 RTN H053 MON H054 PSE H055 CF10 H056 Rd H057 RTN H058 TUES H059 PSE H060 CF10 H061 Rd H062 RTN H063 WED H064 PSE H065 CF10 H066 Rd H067 RTN H068 THURS H069 PSE H070 CF10 H071 Rd H072 RTN H073 FRI H074 PSE H075 CF10 H076 Rd H077 RTN L001 LBL L *DAYS BETWEEN DATES L002 x<>y L003 STO T L004 x<>y L005 XEQ I001 L006 STO S L007 RCL T L008 XEQ I001 L009 RCL S L010 x<>y L011 - L012 RTN M001 LBL M *DATE+ M002 STO S M003 x<>y M004 XEQ I001 M005 RCL S M006 + M007 XEQ J001 M008 RTN

Edited: 16 Sept 2011, 9:26 p.m.


[ Return to the Message Index ]

Go back to the main exhibit hall