Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    NJ USA
    Posts
    19

    Unanswered: 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.


    __________________
    M. Jain

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    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.

  3. #3
    Join Date
    Nov 2003
    Location
    NJ USA
    Posts
    19
    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.
    M. Jain

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •