System Functions
JUL( ) Return Julian Date
   
Formats 1. Julian from Numeric: JUL(year,month,day[,ERR=stmtref]) 
2. Julian from Day Format: JUL(string$[,ERR=stmtref])

Where:

year Numeric expression of the year. Use 0 (zero) for the current year. If your value is less than 100, the current century is added to the value.
month Numeric expression of the month. Use 0 for the current month.
day Numeric expression of the day. Use 0 for the current day.
string$ String expression containing the date to convert. Format must match the current DAY_FORMAT
stmtref Program line number or statement label to which to transfer control if an error occurs..
   
Returns Julian date (converted from year, month, day).
   
Description The JUL( ) function is used to convert a date from year, month, day to a Julian date. The Julian date is an integer: the number of days since the system base-date. By default, in ProvideX this is January 1, 1970. Use the 'BY' system parameter to change the base date.


*Note* Historically the true Julian calendar starts sometime around 4713 BC., but because of errors in early calendars, dates prior to 1200 are not reliable. If you want the JUL( ) function to return dates based roughly on the Julian calendar, set the 'BY' system parameter to 0 (zero).


   
See Also DAY_FORMAT Directive
DAY System Variable
DTE( ) Convert Date
'BY'= System Parameter
'JO'= System Parameter The 'JO' parameter is a +PxPlus Exclusive
   
Examples The following example converts a given date to Julian format and calculates the difference from the current Julian date:

0010 INPUT "Enter Date (MM/DD/YY):",X$:"00/00/00"
0020 LET M=NUM(X$(1,2))
0030 LET D=NUM(X$(3,2))
0040 LET Y=NUM(X$(5,2))
0050 LET N=JUL(Y,M,D,ERR=0100)
0060 PRINT "That is ",N-JUL(0,0,0)," days from now"
0070 STOP
0100 PRINT "Invalid date"; GOTO 0010
-:RUN
Enter Date (MM/DD/YY):03/31/99
That is 23 days from now
-:

In the following example, the JUL( ) function accepts a valid DAY string and returns the corresponding Julian date:

X$="01/01/A0" DAY_FORMAT "MM/DD/AA" PRINT JUL(X$)
10957
PRINT DTE(10957:"%Y %Ml %D")
2000 January 1

JUL( ) can be used to determine if a given date is either Saturday or Sunday. Since the JUL( ) function returns a day number, JUL (...) | 7 would provide a week day number in the range 0-6. Depending on what is configured as the base year (standard for ProvideX is January 1st 1970, compatibility mode is 4714 BC) the day number changes. The system parameter of JO can also be used to adjust the Julian date for compatibility purposes with other languages.

For example if the base year is set to the ProvideX standard of 1970 ('BY'=1970)

Sun=3, Mon=4, Tue=5, Wed=6, Thu=0, Fri=1, Sat=2

The weekend can be tested as follows:

if ((jul(y,m,d)+3)|7)>=5 then <WEEKEND>

However, if 'BY'=0,

Sun=6, Mon=0, Tue=1, Wed=2, Thu=3, Fri=4, Sat=5

The weekend can be tested as follows:

if ((jul(y,m,d))|7)>=5 then <WEEKEND>



*Note* A simple technique to check for the weekend, regardless of the setting of the base year, is to subtract the JUL value from the JUL of a known date. For example January 1st 2000 was a Saturday thus MOD(JUL(m,d,y) - JUL(2000,1,1),7) will yield 0 or 1 for Saturday and Sunday respectively.