Microsoft
Software
Hardware
Network
Question : Declaring variables in stored porcedure
Hi,
I'm using this expesion to define what's the first day of the week...
set DATEFIRST 1
SELECT CONVERT(VARCHAR(10),DATEAD
D(dd, 1 - DATEPART(dw, getdate()), getdate()),21)
Now, I would like to set IF condition in my stored porcedure to define my @datestamp variable as:
If GETDATE() is equal to SELECT CONVERT(VARCHAR(10),DATEAD
D(dd, 1 - DATEPART(dw, getdate()), getdate()),21) then my @datestamp should have value getdate()-3.
ELSE if current datei s not equal to SELECT CONVERT(VARCHAR(10),DATEAD
D(dd, 1 - DATEPART(dw, getdate()), getdate()),21) then my @datestamp should have value getdate()-1.
I would appreciate your help about this.
Thank you very much...
Regards
Answer : Declaring variables in stored porcedure
IF CONVERT(VARCHAR(10),DATEAD
D(dd, 1 - DATEPART(dw, getdate()), getdate()),21) = CONVERT(VARCHAR(10), GETDATE(),21)
SET @datestamp = DATEADD(dd, -3, GETDATE())
ELSE
SET @datestamp = DATEADD(dd, -1, GETDATE())
PRINT @datestamp
Random Solutions
Asp.Net I need help. I am not passing Date values to my the Conrol Parameters?? in a SqlDatasource using Ajax
visual studio 2008 installation issue
If folder does not exist, then create one
How to burn multiple copies with roxio creator
BESX 5.0.1.4 and Exchange 2010 Users can't activate enterprise email
Physical installation of the Exchange 2007
SSIS and variable issues
How to configure SSG-140 with multiply public IP's on single interface.
Mysql LIKE vs RLIKE
Flag duplicate record