Home > Archive > MS SQL Server > March 2006 > help with stored procedure query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author help with stored procedure query
Fabuloussites

2006-03-26, 8:23 pm

I have a database table that has a starttime, and endtime filed that are
datetime values. for my application, they fields may or may not be null.

I would like to write a query in my stored procedure to return results that
have not expired. However, i don't know how to account for records that
don't have dates.

For instance, if all records had dates, i would just say something like

select * from table where startdate<getdate() and endate>getdate()

however, since some pages never expire (i.e. have null start and end dates),
i don't know how to retreive those as well.

thanks for any assistance.
Fabuloussites

2006-03-26, 8:23 pm

thanks.

"bantar" wrote:
[color=darkred]
> Hi;
>
> Try:
>
> select * from table where (getdate() between startdate and endate) or
> (startdate is null and endate is null)
>
> Cheers
>
> "Fabuloussites" wrote:
>
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com