Results 1 to 3 of 3
  1. #1
    Join Date
    May 2013
    Posts
    5

    Unanswered: Problem in converting date format

    Hi

    I am trying to convert a date that is of the format
    Code:
    Jul 6 2013 11:59PM
    to
    Code:
     06/07/2013
    using the below:

    Code:
    SELECT CONVERT(varchar, 'Jul 4 2013 11:59PM', 101)
    but am not getting the desired output. Is there is a way in which this can be acheived?

    Thanks

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Your desired output format is 103 for day/month/year
    This will work if your input is a date e.g.
    Code:
    declare @dt datetime
    set @dt='20130704'
    select convert(char(10),@dt,103)
                
     ---------- 
     04/07/2013
    Since your input is a char string you'll have to convert your 101 format char to a date
    Then convert the date to a 103 format char i.e.
    Code:
    select convert(char(10), convert(datetime,'Jul 4 2013 11:59PM', 101), 103)
                
     ---------- 
     04/07/2013

  3. #3
    Join Date
    May 2013
    Posts
    5
    thanks pdreyer! it worked

Posting Permissions

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