November 25, 2009 at 4:03 am
Hi am passing Startdate and EndDate as an input parameter in my stored procedure.
How do I work out the scenario where say the sartdate is passed as NULL and the enddate is passed some value. So based on which I would fetch the record from table where the DateField column data is less then the end date. The same scenario applies to StartDate parameter as well.
I have tried something like
Time_Date >= CONVERT(varchar(10),@startdate,101) and Time_Date <= CONVERT(varchar(10),@enddate,101).
Any help would be appreciated.
November 25, 2009 at 5:46 am
Hi,
set the initial values if dates are null.
if @startdate is null
set @startdate='19000101' --dummy start date
if @enddate is null
set @enddate=getdate() --current date as end date
and in where clause add Time_Date between @startdate and @enddate
hope this will help..
regards
Raghavendra N S
November 25, 2009 at 7:40 am
yes it did..help thanks Raghav 🙂
November 25, 2009 at 3:10 pm
Keep it simple...
WHERE Time_Date between ISNULL(@startdate,0) and @enddate
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply