Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to find the first day of the month given by the user in any date format

Chandhan S JJan 7 2021

Hi All,
I've seen all the previous discussions about finding the first day of the month using sysdate but I'm trying to get the same first day of the month from the user input but not able to do so. Request you to help me out.

Queries Used:
First day of the current month
select to_char(trunc(sysdate,'MM'),'DAY') from dual;
The above query is working fine

But my query is not working
select to_char(trunc(&asysdate,'MM'),'DAY') from dual;
select to_char(trunc(to_date(&asysdate),'MM'),'DAY') from dual;
I passed 01-JAN-21 as input but got the below error
ORA-00904: "JAN": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 1 Column: 25

Thanks,
Chandhan

This post has been answered by cormaco on Jan 7 2021
Jump to Answer
Comments
Post Details
Added on Jan 7 2021
2 comments
1,287 views