Maliki Hassani
asked on
Oracle: Syntax for replacing 7 day query to know all Mondays
Experts,
I have a query that pulls the date range from yesterday to 7 days back.
Code snippet:
WHERE UDF_CONVERT_UNIX_DATETIME( DATE_CREAT ED, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '7' DAY)
AND UDF_CONVERT_UNIX_DATETIME( DATE_CREAT ED, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY)
I would like to replace the 7 day so that it knows to pull all Mondays.
Any idea on how I can do this?
Thanks
(Oracle 10)
I have a query that pulls the date range from yesterday to 7 days back.
Code snippet:
WHERE UDF_CONVERT_UNIX_DATETIME(
AND UDF_CONVERT_UNIX_DATETIME(
I would like to replace the 7 day so that it knows to pull all Mondays.
Any idea on how I can do this?
Thanks
(Oracle 10)
ASKER
Sorry,
When I say Monday, I mean that regardless of the day it is my query should pull data from yesterday and and exceed Monday's date.
Example:
If today I run my current query it goes back and pulls 7 days worth of data. Which goes past Monday and not what I am wanting. I would like for it to stop always on Monday, regardless of what day I run my query.
When I say Monday, I mean that regardless of the day it is my query should pull data from yesterday and and exceed Monday's date.
Example:
If today I run my current query it goes back and pulls 7 days worth of data. Which goes past Monday and not what I am wanting. I would like for it to stop always on Monday, regardless of what day I run my query.
ASKER
Correction to the top paragragh.
I mean that regardless of the day it is my query should pull data from yesterday and NOT exceed Monday's date.
I mean that regardless of the day it is my query should pull data from yesterday and NOT exceed Monday's date.
an example of few sample records and what output need would be easy to understand.
try this. Not sure whether i got your question right .
WHERE UDF_CONVERT_UNIX_DATETIME( DATE_CREAT ED, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '7' DAY)
AND UDF_CONVERT_UNIX_DATETIME( DATE_CREAT ED, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY)
and to_char((TRUNC(SYSDATE) - INTERVAL '7' DAY),'D') >= 2
WHERE UDF_CONVERT_UNIX_DATETIME(
AND UDF_CONVERT_UNIX_DATETIME(
and to_char((TRUNC(SYSDATE) - INTERVAL '7' DAY),'D') >= 2
ASKER
Hi,
I am trying to do something like this
WHERE UDF_CONVERT_UNIX_DATETIME( DMR.SCHEDU LED_START_ DATE_TIME, 'US/Eastern') >= ((TRUNC(SYSDATE) - INTERVAL '7' DAY),'D') >= 2) <-- Fixed for Monday only
AND UDF_CONVERT_UNIX_DATETIME( DMR.SCHEDU LED_START_ DATE_TIME, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY)
Any ideas?
I am trying to do something like this
WHERE UDF_CONVERT_UNIX_DATETIME(
AND UDF_CONVERT_UNIX_DATETIME(
Any ideas?
did you try what i gave you ?
ASKER
Yes,
but no records are being displayed.
WHERE UDF_CONVERT_UNIX_DATETIME( DMR.SCHEDU LED_START_ DATE_TIME, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '7' DAY)
AND UDF_CONVERT_UNIX_DATETIME( DMR.SCHEDU LED_START_ DATE_TIME, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY)
and to_char((TRUNC(SYSDATE) - INTERVAL '7' DAY),'D') >= 2
but no records are being displayed.
WHERE UDF_CONVERT_UNIX_DATETIME(
AND UDF_CONVERT_UNIX_DATETIME(
and to_char((TRUNC(SYSDATE) - INTERVAL '7' DAY),'D') >= 2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
* do you want the 7 last mondays?
* or from last monday to this monday?
* or something else