Showing posts with label intention. Show all posts
Showing posts with label intention. Show all posts

Sunday, February 12, 2012

Convert Datetime of query otimize.

Hello All,

In following statement in SQL, Which one should I use and why. My intention to get the record between the date and with style 101.
Which is in following is right one. If I use first('A') then it's little bit slower than second 'B'. So Please suggest me asap.

A.

convert(datetime,convert (nvarchar,Cert_WarehouseDetails.IssuedDateX,101)) <= '3/29/2004')
and
(Cert_WarehouseDetails.IssuedDateX is NOT NULL AND
convert(datetime,Cert_WarehouseDetails.IssuedDateX ,101) <= '3/11/2004')
convert(datetime,convert(nvarchar,Cert_WarehouseDe tails.IssuedDateX,101)) <= '3/12/2004')

B
Instead that Can I use like below, as

(convert(datetime,Cert_WarehouseDetails.IssuedDate X,101) >= '1/1/2004') AND
(Cert_WarehouseDetails.IssuedDateX is NOT NULL AND
convert(datetime,Cert_WarehouseDetails.IssuedDateX ,101) <= '3/11/2004')

Please reply to me asap.

Regards,
M. J.

__________________Replace all occurrances of <= and >= along with the date specified with < original_date_plus_1 and > original_date_minus_1. This way you won't have to deal with CONVERT.|||Originally posted by rdjabarov
Replace all occurrances of <= and >= along with the date specified with < original_date_plus_1 and > original_date_minus_1. This way you won't have to deal with CONVERT.

Do I have to use 'nvarchar' while converting to datetime.