Sql Date and Time Functions

The Tutorial illustrate a function to extract the day of week, name of month, name of day, day of year, number of week.

Sql Date and Time Functions

Sql Date and Time Functions

     

The Tutorial illustrate a function to extract the day of week, name of month, name of day, day of year, number of week.

Understand with Example

The section of this tutorial illustrate an example from 'Sql Date and Time Functions'.

Query (DAYOFWEEK) :-Here is the query for extracting the day of week. This function returns a numeric value ranging from(1-7).

 

 

 

 

 

SELECT DAYOFWEEK(CURRENT_TIMESTAMP);

Output:-

Query (MONTHNAME) :-Here is the query for extracting the Name of Month. This function returns a name of the month ranging from (January-December). 

SELECT MONTHNAME('2008-12-15');

Output:-

Query (DAYNAME) :-Here is the query for extracting the Name of the day. This function returns the name of the day ranging from (Sunday-Saturday).  

SELECT DAYNAME('2008-12-15');

Output:-

Query (DAYOFYEAR):-Here is the query for extracting the day of year. This function returns the day of the year ranging from (1-365).  

SELECT DAYOFYEAR('2008-12-15');

Output:-

Query (WEEK) :-Here is the query for extracting the number of week. This function returns the number of the week ranging from (1-53).

SELECT WEEK('2008-12-15');

Output:-