JULIAN_DAY

The JULIAN_DAY function returns an integer value that represents a number of days from January 1, 4713 B.C. (the start of the Julian date calendar) to the date that is specified in the argument.

Read syntax diagramSkip visual syntax diagramJULIAN_DAY( expression)

The schema is SYSIBM.

The argument must be an expression that returns one of the following data types: a date, a timestamp, or a valid string representation of a date or timestamp. An argument with a character string data type must not be a CLOB. An argument with a graphic string data type must not be a DBCLOB. A string argument must have an actual length that is not greater than 255 bytes. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.

If expression is a timestamp with a time zone, or a valid string representation of a timestamp with a time zone, the result is determined from the UTC representation of the datetime value.

The result of the function is a large integer.

The result can be null; if the argument is null, the result is the null value.

Examples for JULIAN_DAY

Example 1
Using sample table DSN8C10.EMP, set the integer host variable JDAY to the Julian day of the day that Christine Haas (EMPNO = '000010') was employed (HIREDATE = '1965-01-01'). The result is that JDAY is set to 2438762.
   SELECT JULIAN_DAY(HIREDATE)
     INTO :JDAY
     FROM DSN8C10.EMP
     WHERE EMPNO = '000010';
Example 2
Set integer host variable JDAY to the Julian day for January 1, 1998. The result is that JDAY is set to 2450815.
   SELECT JULIAN_DAY('1998-01-01')
     INTO :JDAY
     FROM SYSIBM.SYSDUMMY1;
Example 3
The following invocations of the JULIAN_DAY functions all return the same result, which is 2452642. When the input argument contains a time zone, the result is determined from the UTC representation of the input value. The string representations of timestamps with a time zone in the example SELECT statement all have the same UTC representation: 2003-01-02-20.00.00.
SELECT JULIAN_DAY('2003-01-02-20.00.00'), 
			JULIAN_DAY('2003-01-02-12.00.00-08:00'), 
			JULIAN_DAY('2003-01-03-05.00.00+09:00') 
		FROM SYSIBM.SYSDUMMY1;