Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Unanswered: Convert varchar to datetime

    I have a column that holds dates but is varchar(50) and contains data in the following format:

    01/12/2003

    Code:
    SET DATEFORMAT dmy
    DECLARE @Data DATETIME
    SET @Data = 01/01/2004
    SELECT * FROM Lista WHERE CONVERT(DATETIME, Data) < @Data

    With this code it does not return no result. But if to change the operator returns all the registers. E all the registered in cadastre dates are 1/1/2003

    Help me please.

  2. #2
    Join Date
    Sep 2003
    Location
    Germany
    Posts
    63
    Hi there,

    instead of
    Code:
    SET @Data = 01/01/2004
    you should try
    Code:
    SET @Data = '01/01/2004'
    and it should work!

    Greetings,
    Carsten

  3. #3
    Join Date
    Nov 2003
    Posts
    2

    Thumbs up Thanks

    Very thanks!
    You really it saved my day.
    Thanks

Posting Permissions

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