converting military time to standard time

  • I have a table that stores date time info. I have starting time and ending time. IN the table it stores like this

    starting time- 1/1/1900 3:00:00 PM

    ending time - 1/1/1900 4:00:00 PM

    starting_time- 1/1/1900 6:00:00 AM

    ending_tme = 1/1/1900 7:00:00 AM

    when i display the info it shows up like this

    starting time - 16:00:00

    ending time - 17:00:00

    i want to show it in regular time with AM and PM.

    Here is teh SQL

    SELECT Server_Name.Server_Name AS servername, Schedule_Info.ID AS id, starting_time=CONVERT(CHAR(8),Schedule_Info.Starting_Time,8),

    ending_time=CONVERT(CHAR(8),Schedule_Info.ending_Time,8), Schedule_Info.Title AS Title,

    CONVERT(VARCHAR(8),Schedule_Info._Date,1)as _date, Users.FirstName, Users.LastName, Schedule_Info.serverid

    FROM Schedule_Info INNER JOIN

    Users ON Schedule_Info.userid = Users.UserID INNER JOIN

    Server_Name ON Schedule_Info.serverid = Server_Name.Serverid

    WHERE (Users.Username = 'test') order by servername,_date

  • SELECTLTRIM(STUFF(RIGHT(CONVERT(VARCHAR(26), CURRENT_TIMESTAMP, 109), 14), 9, 4, ''))


    N 56°04'39.16"
    E 12°55'05.25"

  • Thanks it worked

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply