Julianday Function in SQLite

SQLite Julianday Function To convert a date as a Julian Day the SQLite Julianday function is used. The resultant is thus a floating-point number. A Julian Day can be simply understood as the number of days since November 24, 4714 BC 12:00 pm Greenwich time in the Gregorian calendar.

Syntax:

julianday(timestring [, modifier1, modifier2, ... modifier_n ] )   

Example 1:

SELECT julianday('now');

Output:

2458700.5

Explanation: In the above example, we are retrieving the current date.

Example 2:

SELECT julianday('now', 'start of month');

Output:

2458696.5

Explanation: In the above example, we are retrieving the first day of the month.

Example 3:

SELECT julianday('2019-08-05', 'start of month');

Output:

2458696.5

Explanation: In the above example, we are retrieving the first day of the month.

Example 4:

SELECT julianday('now', 'start of month','+1 month', '-1 day');

Output:

2458726.5

Explanation: In the above example, we are retrieving the last day of the month.

Example 5:

SELECT julianday('2019-08-05', 'start of month','+1 month', '-1 day');

Output:

2458726.5

Explanation: In the above example, we are retrieving the last day of the month.

Example 6:

SELECT julianday('now','+2 years');

Output:

2459431.5

Explanation: In the above example, we are adding 2 years to the current date.

Example 7:

SELECT julianday('2019-08-05','+2 years');

Output:

2459431.5

Explanation: In the above example, we are adding 2 years to the specified date.

Example 8:

SELECT julianday('now','+2 days');

Output:

2458702.5

Explanation: In the above example, we are adding 2 days to the current date.

Example 9:

SELECT julianday('2019-08-05','+2 days');

Output: 2458702.5

Explanation: In the above example, we are adding 2 days to the specified date.

Example 10:

SELECT julianday('2019-08-05','-2 days');

Output:

2458698.5

Explanation: In the above example, we are subtracting 2 days from the specified date.

Please follow and like us:
Content Protection by DMCA.com