Results 1 to 2 of 2

Thread: Time format in SQL

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    58

    Time format in SQL

    Hello,

    I am taking datetime value from a table MA and separating date and time by using CONVERT function.

    CONVERT(VARCHAR(12), MA.ArrivalDate, 101) AS ArrivalDate, '
    CONVERT(VARCHAR(12), MA.ArrivalDate, 108) AS ArrivalTime,

    but my ArrivalTime is coming as 13:01:00. I want to convert this time as 1:01:00. I have to do this conversion in my stored proc, not in my code. can you help ..? Thanks

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Time format in SQL

    Use a style that does not return the time using the 24 Hour clock. Then parse out the time portion.

    LTRIM(SUBSTRING(CONVERT(VARCHAR(30), MA.ArrivalDate, 109) , 12, 9)) AS ArrivalTime
    Last edited by brucevde; Sep 7th, 2006 at 03:01 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width