MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB FROM_DAYS() Function



The MariaDB FROM_DAYS() function takes a numeric representation of the day and returns a date value.

This function is to be used only with dates within the Gregorian calendar.

Note: The TO_DAYS() function which is the reverse of the FROM_DAYS() function.

Syntax

FROM_DAYS(numeric_day)

Parameters

numeric_day Required. Specify the numeric day to convert to a date.

Return Value

Returns the date converted from numeric days.

Example 1:

The example below shows the usage of FROM_DAYS() function.

SELECT FROM_DAYS(737289);
Result: '2018-08-18'

SELECT FROM_DAYS(737290);
Result: '2018-08-19'

SELECT FROM_DAYS(737291);
Result: '2018-08-20'

Example 2:

Consider a database table called Employee with the following records:

EmpIDNameCityAgeNumeric DOJ
1JohnLondon25737204
2MarryNew York24737347
3JoParis27737584
4KimAmsterdam30737688
5RameshNew Delhi28737722
6SureshMumbai28738515

The statement given below can be used to convert the records of column [Numeric DOJ] into a date:

SELECT *, FROM_DAYS(`Numeric DOJ`) AS Date_of_Joining FROM Employee;

This will produce the result as shown below:

EmpIDNameCityAgeNumeric DOJDate_of_Joining
1JohnLondon257372042018-05-25
2MarryNew York247373472018-10-15
3JoParis277375842019-06-09
4KimAmsterdam307376882019-09-21
5RameshNew Delhi287377222019-10-25
6SureshMumbai287385152021-12-26

❮ MariaDB Functions