Hello...
I am running into a problem while running a query..can some1 help..
this is the query :
**************
SELECT *
from Table S
where S.dtDate1 BETWEEN dateadd(year,1, dateadd(month,-1,getdate()))
AND dateadd(day,-1,(dateadd(mont h,1,dateadd(yea r,1,dateadd(mon th,-1,getdate())))) )
***************
(first part of the date calculation comes out to be '2005-05-01' and
second part is '2005-05-31')
Here is the interesting twist:
The query runs right if the first date in the between clause is
entered directly i.e. the query wud run right if i rite it as
SELECT *
from vCustomerProduc tDetail S
where S.dtDate1 BETWEEN '2005-05-01'
AND dateadd(day,-1,(dateadd(mont h,1,dateadd(yea r,1,dateadd(mon th,-1,getdate())))) )
The funny part is the ending date in the between part is depending on
the starting date if u notice..so if there is somethg rong in the
first part there shud be somethg rong with the second too if u get wat
i am saying but the query runs right with the second part left as it
is..
can some1 please help..
thanks
-Raghu
I am running into a problem while running a query..can some1 help..
this is the query :
**************
SELECT *
from Table S
where S.dtDate1 BETWEEN dateadd(year,1, dateadd(month,-1,getdate()))
AND dateadd(day,-1,(dateadd(mont h,1,dateadd(yea r,1,dateadd(mon th,-1,getdate())))) )
***************
(first part of the date calculation comes out to be '2005-05-01' and
second part is '2005-05-31')
Here is the interesting twist:
The query runs right if the first date in the between clause is
entered directly i.e. the query wud run right if i rite it as
SELECT *
from vCustomerProduc tDetail S
where S.dtDate1 BETWEEN '2005-05-01'
AND dateadd(day,-1,(dateadd(mont h,1,dateadd(yea r,1,dateadd(mon th,-1,getdate())))) )
The funny part is the ending date in the between part is depending on
the starting date if u notice..so if there is somethg rong in the
first part there shud be somethg rong with the second too if u get wat
i am saying but the query runs right with the second part left as it
is..
can some1 please help..
thanks
-Raghu
Comment