| Author |
Topic |
|
carla
Starting Member
12 Posts |
Posted - 2011-01-12 : 12:39:21
|
| DECLARE @year as intDECLARE @month as intset @month = month(Dateadd(month,2,getdate()) IF month(getdate())= 12 BEGIN set @year = year(getdate())+ 1 ENDELSE BEGIN set @year = year(getdate()) ENDprint @yearprint @monthSELECT * FROM tblDominio where month(dtmDominioFechaVencimiento)= month and year(dtmDominioFechaVencimiento) > DateAdd(month,3,getdate()) HELLO, im getting this error "Msg 156, Level 15, State 1, Line 5Incorrect syntax near the keyword 'IF'."but im lost and I dont know what Im missing, could u help me?carla |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-12 : 12:44:11
|
| you've unclosed braces in set. it should beset @month = month(Dateadd(month,2,getdate()))------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-01-12 : 12:44:38
|
| You are missing a parenthesis:set @month = month(Dateadd(month,2,getdate()))EDIT: Too slow. :( |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-12 : 12:45:36
|
| i dont think the below condition is rightyear(dtmDominioFechaVencimiento) > DateAdd(month,3,getdate()) can you explain what you're trying to do------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
carla
Starting Member
12 Posts |
Posted - 2011-01-12 : 13:03:50
|
| Thank you very mucho for your answers, What I'm trying to check on a table all the domains that expire in the next 3 months, thats why im using the select for...carla |
 |
|
|
carla
Starting Member
12 Posts |
Posted - 2011-01-12 : 13:06:14
|
Thank you very much!! for your answers, What I'm trying to check on a table all the domains that expire in the next 3 months, thats why im using the select for...carlaquote: Originally posted by visakh16 i dont think the below condition is rightyear(dtmDominioFechaVencimiento) > DateAdd(month,3,getdate()) can you explain what you're trying to do------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
carla |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-12 : 13:07:36
|
then use where likeSELECT * FROM tblDominio where dtmDominioFechaVencimiento >= dateadd(dd,datediff(dd,0,getdate()),0) and dtmDominioFechaVencimiento < dateadd(mm,datediff(mm,0,getdate())+3,0)+1 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
carla
Starting Member
12 Posts |
Posted - 2011-01-12 : 13:29:52
|
thnks for your help! =) have a nice day!quote: Originally posted by visakh16 then use where likeSELECT * FROM tblDominio where dtmDominioFechaVencimiento >= dateadd(dd,datediff(dd,0,getdate()),0) and dtmDominioFechaVencimiento < dateadd(mm,datediff(mm,0,getdate())+3,0)+1 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
carla |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-12 : 13:31:34
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|