NEXT_DAY Vs DAYNAME Top SQL Examples

The NEXT_DAY function gives you DATE of the DAY according to DAY you mentioned in SQL. The DAYNAME function gives you the name of the DAY. Below are the best DB2 examples.


You can opt-out anytime you want.


SQL Query Example NEXT_DAY.

SELECT ORDER_DATE
,SHIP_DATE(ORDER_DATE, 'MONDAY')
FROM ORDER_TABLE
WHERE EXTRACT(YEAR FROM ORDER_DATE) = 2019;

It calculates following MONDAY Date from ORDER_DATE.

Advertisements

SQL Query Example DAYNAME, DAYOFWEEK, MONTHNAME.

SELECT CURRENT TIMESTAMP
,DAYNAME(CURRET TIMESTAMP)
,DAYOFWEEK(CURRENT TIMESTAMP)
,MONTHNAME(CURRENT TIMESTAMP)
FROM SYSIBM.SYSDUMMY1;

The above query extracts Day name, Day of week, and Month name.

DAYNAME:

Sunday, Monday,…

DAYOFWEEK:

1-Sunday, 2-Monday…

MONTHNAME:

JANUARY, FEBRUARY…

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.