Forum

SQL Query to Find t...
 
Share:
Notifications
Clear all

SQL Query to Find the day name of 2021 new year day from Sysdate?


Posts: 27
Admin
Topic starter
(@vinodkrsetty)
Eminent Member
Joined: 6 years ago

How to Find the day name of the 2021 new year day from the system?

3 Replies
Posts: 46
Guest
(@Gangadhar Rao)
Eminent Member
Joined: 5 years ago

Hi you can use the DAY NAME function to get the day name of the new year 2021

Query: 

SELECT DAYNAME("2021-01-01 12:01:01");

You will get the output as Friday. 

Reply
Posts: 1
Guest
(@Mahesh Karpe)
New Member
Joined: 4 years ago

Select to_char(to_date('01-01-2020','DD-MM-YYYY'),'DAY') AS DAY from dual;

Reply
Posts: 69
Guest
(@Sai Ram)
Trusted Member
Joined: 5 years ago

Assuming that you want to find the day name of January 1, 2021 (New Year's Day) from the current system date, you can use the following SQL query:              

SELECT TO_CHAR(TO_DATE('01-JAN-2021', 'DD-MON-YYYY'), 'DAY') AS DAY_NAME
FROM DUAL;

Explanation:

* TO_DATE('01-JAN-2021', 'DD-MON-YYYY') converts the string '01-JAN-2021' into a date value.
* TO_CHAR(<date>, 'DAY') converts the date value into a string that represents the day name (e.g., 'FRIDAY').
* FROM DUAL is required in Oracle to select a constant value.

This query should return the day name of January 1, 2021 from the current system date.

Reply

Leave a reply

Author Name

Author Email

Title *

Preview 0 Revisions Saved
Share: