New Zealand
Asked — Edited

Comparing Dates

Hi All

I am trying to write a script that loads a text file and announces messages.... Eg. $Start_Date,$End_Date,$Message 12/11/2013, 12/16/2013, Concert in the Park this week Etc.

Problem I have is that EZ-Script runs a calculation on the dates so that they become month divided by Day divided by year... So as a work around I separated the date into integers. Eg. $Start_Month, $Start_Day, $Start_Year, $End_Month, $End_Day, $End_Year, $Message 12, 11, 2013, 12, 16, 2012, Happy Birthday George

Now it seems to me the best way to compare the Start_dates and End_Dates with the current date is to convert them to a digital format first (Preventing complications when dates cross years).

My question for the masses is :
Has anyone got a script to convert a Georgian date into a Julian number?

I can only find complicated formula and ready made converters. I need to be able to take the three variables $X_Day, $X_Month and $X_Year and end up with a Julian number.

@Tameion


ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

United Kingdom
#1  

Have you tried using different date formats i.e. 2013-01-24?

Georgian to Julian is a very complex formula from what I remember... Is there not an easier way of doing it?

PRO
New Zealand
#2  

Hey Rich.... Nah I found it problemattic converting back and forth and then comparing strings using the date function.... something DJ has set up stores a different result when I compare and print .... anyway I found a wiki on calculating it so had a go myself... I was just being lazy and wanted to avoid another late night but I'm hooked on a project! (It's 2:45am and I have work in the morning.... LOL)

Anyway I thought I'd post the result here .... it's a little spaghetti and I had to loop it a bit as I had to use the Round function to fill in for the lack of integer function... but where there is a will there is a way.

The calculator will give you the current date as a Julian. Then what ever other date yu convert can be compared to this for an past or future comparison.

#Julian Date Calculator

Credit to http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html

$Y=$Year $M=$Month $D=$Day

$A1 = $Y/100 $A2=Round($A1,0) IF ($A1<$A2) $A=$A2-1 ElseIF ($A1>=$A2) $A=$A2 ENDIF

$B1 = $A/4 $B2=Round($B1,0) IF ($B1<$B2) $B=$B2-1 ElseIF ($B1>=$B2) $B=$B2 Endif

$C1 = 2 - $A + $B $C2=Round($C1,0) IF ($C1<$C2) $C=$C2-1 ElseIF ($C1>=$C2) $C=$C2 ENDIF

$E1 = 365.25 * ($Y+4716) $E2=Round($E1,0) IF ($E1<$E2) $E=$E2-1 ElseIF ($E1>=$E2) $E=$E2 ENDIF

$F1 = 30.6001 * ($M+1) $F2=Round($F1,0) IF ($F1<$F2) $F=$F2-1 ElseIF ($F1>=$F2) $F=$F2 ENDIF

$JD= $C + $D + $E + $F - 1524.5 Print ($JD)