0

I want to convert a datetime variable in SQL-Server to string and compare it with an empty string:

CONVERT(varchar(20), @DATEDEB, 1) =''

This is the test I have in my code:

IF (@N_CATComp = 4) AND (@EXON='' OR CONVERT(varchar(20), @DATEDEB, 1) ='' OR CONVERT(varchar(20), @DATEFIN, 1) = '') 

the test works even if datedeb and datefin empty

2 Answers 2

2

If you want to compare the dates to NULL then you can simply try to use the IS [NOT] NULL

Determines whether a specified expression is NULL.

Something like

@myDate IS NULL AND @myDate1 IS NOT NULL

By using this you don't have to convert your datetime to a string variable.

Sign up to request clarification or add additional context in comments.

Comments

0

OKay , the answer is in sql-server, @DATEDEB<>'01/01/1900' which is the defult date that sqlç-serveur takes

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.