Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 21, 2013 11:17 PM by oned_gk
Participant
1065 Points
618 Posts
Feb 21, 2013 09:21 PM|LINK
Hello, In my where clause.. I have like this..
AND evt.EventDate >= @firstDay AND evt.EventDate < @lastDay
But, @firstDay and @lastDay can be null in that case search should return all results, how can I do that?
All-Star
112168 Points
18255 Posts
Moderator
Feb 21, 2013 09:38 PM|LINK
OR @firstDay IS NULL
And the same for lastDay.
31671 Points
6473 Posts
Feb 21, 2013 10:21 PM|LINK
set default value of @firstDay to lowest value like 1/1/2000 and @lastDay to highest value like 1/1/2050
<SelectParameters> <asp:Parameter DefaultValue="1/1/2000" Name="firstDay" Type="DateTime" /> <asp:Parameter DefaultValue="1/1/2050" Name="lastDay" Type="DateTime" /> </SelectParameters>
Contributor
2128 Points
459 Posts
Feb 21, 2013 11:11 PM|LINK
try:
AND (evt.EventDate >= @firstDay or @firstDay is null) AND (evt.EventDate < @lastDay or @lastDay is null)
Feb 21, 2013 11:17 PM|LINK
try
AND evt.EventDate >= ISNULL(@firstDay,'2000-01-01') AND evt.EventDate < ISNULL(@lastDay,'2050-01-01')
nissan
Participant
1065 Points
618 Posts
passing null values
Feb 21, 2013 09:21 PM|LINK
Hello, In my where clause.. I have like this..
AND evt.EventDate >= @firstDay
AND evt.EventDate < @lastDay
But, @firstDay and @lastDay can be null in that case search should return all results, how can I do that?
MetalAsp.Net
All-Star
112168 Points
18255 Posts
Moderator
Re: passing null values
Feb 21, 2013 09:38 PM|LINK
OR @firstDay IS NULL
And the same for lastDay.
oned_gk
All-Star
31671 Points
6473 Posts
Re: passing null values
Feb 21, 2013 10:21 PM|LINK
set default value of @firstDay to lowest value like 1/1/2000 and @lastDay to highest value like 1/1/2050
<SelectParameters> <asp:Parameter DefaultValue="1/1/2000" Name="firstDay" Type="DateTime" /> <asp:Parameter DefaultValue="1/1/2050" Name="lastDay" Type="DateTime" /> </SelectParameters>UstesG
Contributor
2128 Points
459 Posts
Re: passing null values
Feb 21, 2013 11:11 PM|LINK
But don't expect me to do your job!
oned_gk
All-Star
31671 Points
6473 Posts
Re: passing null values
Feb 21, 2013 11:17 PM|LINK
try