Forum

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

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

4 Posts
2 Users
0 Reactions
2,898 Views
Posts: 27
Admin
Topic starter
(@vinodkrsetty)
Eminent Member
Joined: 7 years ago

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


3 Replies
Posts: 46
(@Gangadhar Rao)
Joined: 6 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
(@Mahesh Karpe)
Joined: 5 years ago

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


Reply
Posts: 69
(@Sai Ram)
Joined: 6 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: