Click here to Skip to main content
15,900,372 members
Home / Discussions / Database
   

Database

 
QuestionQuerying on null datetime Pin
www.Developerof.NET26-Apr-10 3:44
www.Developerof.NET26-Apr-10 3:44 
AnswerRe: Querying on null datetime Pin
loyal ginger26-Apr-10 3:54
loyal ginger26-Apr-10 3:54 
AnswerRe: Querying on null datetime Pin
Luc Pattyn26-Apr-10 4:08
sitebuilderLuc Pattyn26-Apr-10 4:08 
AnswerRe: Querying on null datetime Pin
Luc Pattyn26-Apr-10 4:15
sitebuilderLuc Pattyn26-Apr-10 4:15 
AnswerRe: Querying on null datetime Pin
Peace ON26-Apr-10 4:17
Peace ON26-Apr-10 4:17 
AnswerRe: Querying on null datetime Pin
PIEBALDconsult26-Apr-10 4:24
mvePIEBALDconsult26-Apr-10 4:24 
GeneralRe: Querying on null datetime Pin
www.Developerof.NET26-Apr-10 20:41
www.Developerof.NET26-Apr-10 20:41 
AnswerRe: Querying on null datetime Pin
Peace ON26-Apr-10 4:26
Peace ON26-Apr-10 4:26 
Following is conditional code that will work for your situation.

declare @date1 as DateTime;
declare @date2 as DateTime;

If both the dates are specified the query goes as follow

set @date1='1970-04-04 00:00:00.000';
set @date2='1978-07-07 00:00:00.000';
if @date1 is null or @date2 is null
begin
select * from tblemployee
end
else
begin
select * from tblemployee WHERE
birthdate between @date1 and @date2
end


If any of the field or both of the field is null then the query goes as follow

set @date1=NULL;
set @date2='1978-07-07 00:00:00.000';
if @date1 is null or @date2 is null
begin
select * from tblemployee
end
else
begin
select * from tblemployee WHERE
birthdate between @date1 and @date2
end
Jinal Desai

QuestionDatabase Mail AS Exchange? Pin
Jassim Rahma24-Apr-10 23:08
Jassim Rahma24-Apr-10 23:08 
AnswerRe: Database Mail AS Exchange? Pin
Mycroft Holmes24-Apr-10 23:40
professionalMycroft Holmes24-Apr-10 23:40 
AnswerRe: Database Mail AS Exchange? Pin
Md. Marufuzzaman24-Apr-10 23:56
professionalMd. Marufuzzaman24-Apr-10 23:56 
QuestionCan't Query with = ISNULL? Pin
#realJSOP23-Apr-10 5:16
professional#realJSOP23-Apr-10 5:16 
AnswerRe: Can't Query with = ISNULL? Pin
Simon_Whale23-Apr-10 5:26
Simon_Whale23-Apr-10 5:26 
GeneralRe: Can't Query with = ISNULL? Pin
Luc Pattyn23-Apr-10 5:28
sitebuilderLuc Pattyn23-Apr-10 5:28 
GeneralRe: Can't Query with = ISNULL? Pin
Simon_Whale23-Apr-10 5:30
Simon_Whale23-Apr-10 5:30 
GeneralRe: Can't Query with = ISNULL? Pin
Md. Marufuzzaman24-Apr-10 1:52
professionalMd. Marufuzzaman24-Apr-10 1:52 
GeneralRe: Can't Query with = ISNULL? Pin
Mycroft Holmes24-Apr-10 13:16
professionalMycroft Holmes24-Apr-10 13:16 
GeneralRe: Can't Query with = ISNULL? Pin
Md. Marufuzzaman24-Apr-10 18:40
professionalMd. Marufuzzaman24-Apr-10 18:40 
AnswerRe: Can't Query with = ISNULL? Pin
Luc Pattyn23-Apr-10 5:27
sitebuilderLuc Pattyn23-Apr-10 5:27 
GeneralRe: Can't Query with = ISNULL? Pin
Corporal Agarn23-Apr-10 8:55
professionalCorporal Agarn23-Apr-10 8:55 
QuestionADO.NET almost nullable column Pin
Yoyosch23-Apr-10 4:36
Yoyosch23-Apr-10 4:36 
AnswerRe: ADO.NET almost nullable column PinPopular
J4amieC23-Apr-10 4:43
J4amieC23-Apr-10 4:43 
AnswerRe: ADO.NET almost nullable column Pin
Mycroft Holmes24-Apr-10 13:23
professionalMycroft Holmes24-Apr-10 13:23 
GeneralRe: ADO.NET almost nullable column Pin
Yoyosch25-Apr-10 21:48
Yoyosch25-Apr-10 21:48 
GeneralRe: ADO.NET almost nullable column Pin
Mycroft Holmes25-Apr-10 22:26
professionalMycroft Holmes25-Apr-10 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.