I'm doing DTS, Here is one of my Sql Query in DTS
Select * From ZT_DailyRpt_Detail
Where
isNumeric(TenDayDate) = 1 And TenDayDate <
Convert(varchar(10),DateAdd(Month,-CAST
((SELECT keepmonth
FROM zt_databackup a, zt_biller b
WHERE a.companycode = b.companycode AND
zt_DailyRpt_Detail.biller_code = b.billercode) AS int),GetDate()),112)
the sub query 【SELECT keepmonth
FROM zt_databackup a, zt_biller b
WHERE a.companycode = b.companycode AND
zt_DailyRpt_Detail.biller_code = b.billercode) AS int】will return a value 6 or 12
for the reason, every month have differnet days, ( some have 31 days , some are 30 days ) I don't want to check the day of date , only to compare month
if sub query return "6" and I do DTS on 2007/07/29 , will select date whichTenDayDate< 2007/01 not TenDayDate<2007/01/29 ( don't want to check the day of date)
does my query correct? if not can you correct it for me? thank you very much
Not sure I understood your problem, but maybe what you're looking for isDATEDIFFsql function?
|||sorry for not describe my question clearly
my problem is
if I want to compare 2 date for example one is 2007/01/22 another is 2007/07/30
2007/07/30 - 2007/01/22 = 2007/06/08 right? that is not what I need
I need the result is 2007/06
I want to do DTS
if user run DTS in 2007/07/28 , want to select the data < 2007/07/28- 6 months , so it would be where data < 2007/01/28
I am not select Data < 2007/01/28 , I want to select Data < 2007/01 ( need not to compare the Day )
thank you
No comments:
Post a Comment