• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Oracle sample query to grab one week's data

Hi,

Can anyone let me know a sample query to pull data for a week

from last Monday to this Monday
0
new_perl_user
Asked:
new_perl_user
  • 2
1 Solution
 
slightwv (䄆 Netminder) Commented:
select * from table_name where
date_column >= to_date('10/03/2011','MM/DD/YYYY') and date_column < to_date('10/11/2011','MM/DD/YYYY');
0
 
new_perl_userAuthor Commented:
something without  hard coding the date because it goes into an automated script. For the above one I need to change date always.
0
 
slightwv (䄆 Netminder) Commented:
You can use sysdate as long as you know when it runs:

select * from table where date_column >= trunc(sysdate)-7 and date_column < trunc(sysdate)+1
0
 
johnsoneSenior Oracle DBACommented:
I would use the NEXT_DAY function.

select * from table where date_column >= next_day(sysdate, 'MONDAY') - 14 and
date_column < next_day(sysdate, 'MONDAY') - 7;
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now