Hi all,
i would want to extract some data from a sql database every day. The date of the scripts needs to be changed to match the current date. Every "find and replace" script is not working on these sql querys, and i'm not quite sure why.
I need help to change this line automaticly every day to both match the current date.
"and (pb2.pdatetime >= '2008/01/20') and (pb2.pdatetime <= '2010/12/20');"
This will "echo" will put out the right date:
set jahr=%date:~-4%
set monat=%date:~-7,2%
set tag=%date:~-10,2%
echo %jahr%/%monat%/%tag%
The whole sql statment has about 720 chars.
Thanks a million for every hint and help
Tarsinion
Find and Replace - Date within SQL Query
Moderator: DosItHelp
Re: Find and Replace - Date within SQL Query
Hi Tarsinion,
I don't understand your problem exactly.
But I make a guess, as you can echo the date, you should be able to echo your "new line" like
Ok, but is the date 2008/01/20 fix or in some way does it depends of today?
Or do you have a problem to switch the line in your sql script?
First you can try something like
SQL_Template.tpl
Then you can each time append simply your created line like.
jeb
I don't understand your problem exactly.
But I make a guess, as you can echo the date, you should be able to echo your "new line" like
Code: Select all
set jahr=%date:~-4%
set monat=%date:~-7,2%
set tag=%date:~-10,2%
set "newLine=and (pb2.pdatetime ^>= '2008/01/20') and (pb2.pdatetime ^<= '%jahr%/%monat%/%tag%');"
echo %newLine%
results (today) to:
and (pb2.pdatetime >= '2008/01/20') and (pb2.pdatetime <= '2010/05/11');
Ok, but is the date 2008/01/20 fix or in some way does it depends of today?
Or do you have a problem to switch the line in your sql script?
First you can try something like
SQL_Template.tpl
Code: Select all
select irgendwas from tabelle where xyz=3
Then you can each time append simply your created line like.
Code: Select all
copy SQL_Template.tpl script.sql
echo %newLine% >>script.sql
jeb