Internet PLC Forum
General => Technical support => Topic started by: secs on April 27, 2016, 09:53:42 AM
-
Hi all.
I need to store say todays date in eeprom and then each day the pcl is fired up calculate the number of days between the stored date and the current one. Any suggestions?
I am using a F2424 at the moment soon to be replaced with a Fx2424
-
I suggest that you convert your day/month/year format to a Julian date. Google this.
I have posted a Julian date conversion algorithm on this site. Search for "Julian" for this thread.
I trans-coded one of the published alorithms from FORTRAN to TBASIC and the results agree with the online calculator at USNO.
' GenJD - custom function to compute Julian Date.
' Algoritm agrees with USNO (United States Naval Observatory) online Julian Date Converter
' at http://aa.usno.navy.mil/data/docs/JulianDate.php
'
' 9/17/2013 is JD 2456553
'
' On entry:
' I = year 2013
' J = month 1..12
' K = day of month
'
' On exit:
' A holds Julian date
'
A = K-32075+1461*(I+4800+(J-14)/12)/4+367*(J-2-(J-14)/12*12) /12-3*((I+4900+(J-14)/12)/100)/4
Good Luck,
Gary D*ickinson
-
Thanks Gary. That will do it :-)
Peter