Name
nasa_tjd_number, nasa_tjd_fraction, merge_nasa_tjd_to_datetime — convert between datetimes and NASA Truncated Julian Date components
Synopsis
integer nasa_tjd_number(
|
in dt datetime); |
double precision nasa_tjd_fraction(
|
in dt datetime); |
datetime merge_nasa_tjd_to_datetime(
|
in tjd_number integer, |
in tjd_fraction double precision); |
Description
NASA Truncated Julian Date (TJD) is a continuous day-numbering system used by spacecraft telemetry and astronomical scheduling. TJD day 0 corresponds to 1968-05-24 00:00:00 UTC; each integer increment advances the date by one day. These functions let Virtuoso datetimes interoperate with TJD values.
nasa_tjd_number returns the integer TJD day number of
dt, discarding the time-of-day part.
nasa_tjd_fraction returns the fractional-day
component of dt as a double in [0.0,
1.0): 0.0 at midnight, 0.5 at noon, etc.
merge_nasa_tjd_to_datetime rebuilds a datetime from a
TJD tjd_number and an optional
tjd_fraction. With one argument it returns a
DATE; with two it returns a full DATETIME. The
fraction must satisfy 0 <= fraction < 1;
otherwise SQL state 22023 (SR644) is raised.
Examples
Example 24.77. Round-trip a datetime through TJD
SQL> select nasa_tjd_number (now()), nasa_tjd_fraction (now());
SQL> select merge_nasa_tjd_to_datetime (20000, 0.5);