![]() |
Excel Query
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 |
Excel Query
"Dave Y" wrote ...
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. -- |
Excel Query
Hi Jamie,
Thank you for reply. I will try giving a CASE Statement a try. Dave Y -----Original Message----- "Dave Y" wrote ... 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. -- . |
All times are GMT +1. The time now is 07:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com