Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using sysdate in an Oracle query

Posted on 2014-03-27
3
Medium Priority
?
789 Views
Last Modified: 2014-03-27
Experts,

Does anyone know the syntax in Oracle to find a date?

Examples:
the first day of the current month
The first day of the current week
0
Comment
Question by:morinia
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 39960061
select trunc(sysdate,'mm') from dual -- first day of month


select trunc(sysdate,'dy') from dual -- first day of week


week start/end is dependent on NLS calendar settings
0
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 500 total points
ID: 39960074
SELECT TRUNC(SYSDATE, 'MM') First_Day_Of_Month,
         TRUNC(TO_DATE(SYSDATE),'D') First_Day_Of_Week
 FROM dual;
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 39960106
TO_DATE(SYSDATE)

don't do TO_DATE() on SYSDATE, it's already a date

  just put the TRUNC directly against the sysdate result as shown in the first post
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question