Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Confusing Code

Author  Topic 

Rita Bhatnagar
Posting Yak Master

172 Posts

Posted - 2001-05-16 : 12:10:46
lstrSQL = lstrSQL & " WHERE a.CostMasterScheduleSessionId = b.CostMasterScheduleSessionId
If alngCareRecipientId <> 0 Then
lstrSQL = lstrSQL & " AND c.CareRecipientId = " & alngCareRecipientId
End If

If adatePeriod <> 0 Then
lstrSQL = lstrSQL & " AND e.StartDateTime >= CvDate('" & Format(adatePeriod, "mm/01/yyyy") & "')"
lstrSQL = lstrSQL & " AND e.StartDateTime < CvDate('" & Format(DateAdd("m", 1, adatePeriod), "mm/01/yyyy") & "')"
End If

This is the code in VB .I changed this in stored procedure like this
.......
@period datetime \*this is adateperiod*AS
Declare @period2 datetime
set @Period2=DateAdd(m, 1, @period)
.....
.....
WHERE a.CostMasterScheduleSessionId = b.CostMasterScheduleSessionId
AND (c.CareRecipientId =@prmCareRecipientID or @prmCareRecipientID<=0)

AND ( @period = 0 or e.StartDateTime between dateadd(day,-day(@period)+1,@period) and
dateadd(day,-day(@period2),@period2))

I am confused at the part @period=0.Is this right or not.
Thanks for any help.

   

- Advertisement -