Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

using sysdate in an Oracle query

Posted on 2014-03-27
3
Medium Priority
?
781 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
[X]
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
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by 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…
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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

688 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