[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Oracle - Date SQL calcs

Posted on 2011-02-21
4
Medium Priority
?
330 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
[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
  • 3
4 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 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 74

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 74

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

649 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