Convert a Julian Day to a Date in PostgreSQL

Here are two ways to convert a given Julian day to its date value in PostgreSQL.

The first method directly inputs the Julian day into the date data type.

The second method uses the to_date() function to return the same result.

Julian day is the number of days since Monday, January 1, 4713 BC using the proleptic Julian calendar, which is November 24, 4714 BC, in the proleptic Gregorian calendar.

Continue reading

How the Strftime() Function Works in SQLite

The SQLite strftime() function enables you to return a date and time value in a specified format.

The actual date/time value returned is based on a time string that you provide as an argument when you call the function, as well as any modifiers you include (as optional arguments). A modifier allows you to change the date, such as add a number of days, set it to local time, etc

Continue reading

How the JulianDay() Function Works in SQLite

The SQLite julianday() function returns the number of days since noon in Greenwich on November 24, 4714 B.C. (using the Proleptic Gregorian calendar).

If using the proleptic Julian calendar, this is Monday, January 1, 4713 BC.

Julian day is the continuous count of days since the beginning of the Julian Period. It’s typically used by astronomers, software, etc to calculate elapsed days between two events.

To use this function, you need to provide a time string, plus any (optional) modifiers. A modifier allows you to change the date, such as add a number of days, set it to local time, etc

Continue reading