Solved

Oracle - Date SQL calcs

Posted on 2011-02-21
4
320 Views
Last Modified: 2012-08-14
Looking for a "between" statement that will go back 30 days from yesterday's date and end at yesterday's date.

Example if the statement ran today:
...where full_date between ('1/21/2011' and '2/20/11')



0
Comment
Question by:carsRST
  • 3
4 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 34943988
where full_date between trunc(sysdate)-31 and trunc(sysdate)-1


if you want to include all time of yesterday then you'll have to include the
time piece in the between

where full_date between trunc(sysdate)-31 and trunc(sysdate)-1 + (86399/86400)
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 34944010
or use >=  <=


where full_date >=trunc(sysdate)-31 and
full_date <= trunc(sysdate)-1 + (86399/86400)

or

where full_date >=trunc(sysdate)-31 and
full_date <= trunc(sysdate)  - (1/86400)

or



where full_date >=trunc(sysdate)-31 and
full_date < trunc(sysdate)     -----  note <  not <=


0
 
LVL 16

Author Closing Comment

by:carsRST
ID: 34944019
sdstuber = great person

Thanks!
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 34944027
and finally, one more option...


where full_date between trunc(sysdate)-31 and trunc(sysdate)- (1/86400)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - CSV to Oracle table 4 71
Oracle Public Synonyms and Privileges 2 65
passing parameters to sql script oracle 4 42
Oracle Insert not working 10 28
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video shows how to recover a database from a user managed backup
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

777 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