using sysdate in an Oracle query

Posted on 2014-03-27
Last Modified: 2014-03-27

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

the first day of the current month
The first day of the current week
Question by:morinia
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 74

Accepted Solution

sdstuber earned 125 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
LVL 41

Assisted Solution

Sharath earned 125 total points
ID: 39960074
         TRUNC(TO_DATE(SYSDATE),'D') First_Day_Of_Week
 FROM dual;
LVL 74

Expert Comment

ID: 39960106

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

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error starting form builder in 11g 2 49
Get data from two MySQL tables 6 66
Oracle Mulit-site configuration 28 74
Oracle function return value when null 2 36
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

752 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