Excel Query

D

Dave Y

Hello,

I have an existing SQL query that I run every day and then
export the results into an excel spreadsheet. The SQL
script that I run returns the previous days information
from the DB using a SYSDATE -1 statement. I know that I
can create an ODBC connection and build and run this query
within Excel itself. My problem is that we work on
Saturdays and if I run the query on Monday it will bring
back zero results because the SYSDATE -1 will bring back
the results from Sunday. As it stands now, I manually edit
the SQL script to bring back the information from
Saturday. How could I write this query within Excel so
that on Mondays only, the query code will know to go back
2 days to get Saturday's info which would be SYSDATE -2
and then the rest of the week the query would just run
SYSDATE -1? If I could accomplish this task, I could give
this Excel spreadsheet to the Mgr. of the deptartment
along with an ODBC Connection and then they could run this
report on their own which would be one less thing on my
plate. Any assistance with this issue will be greatly
appreciated. Thank you in advance.

Dave Y
 
J

Jamie Collins

...
script that I run returns the previous days information
from the DB using a SYSDATE -1 statement.
As it stands now, I manually edit
the SQL script to bring back the information from
Saturday.

I don't have Oracle to check how its proprietary functions work but
could you perhaps test for Monday using:

to_char(sysdate,'DDD')

in a CASE (or equivalent) statement?

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top