1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sql Query for :Converting full date into AM/PM with Time. only.

Discussion in 'C#' started by Pari13, Oct 6, 2010.

  1. Pari13

    Pari13 New Member

    Joined:
    Oct 6, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi All Developer,

    I am waiting for Query that will Converting full date into AM/PM with Time. only.
    in Sql Server.

    For Example:
    2010-06-24 16:00:00.000 will be giving result -->04:00 PM

    2010-09-24 01:00:00.000 will be giving result -->01:00 AM


    Wait For your Reply.

    Thanks.
    Dhimmar
     
  2. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    17
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    Dhimmar u can do this by building a PL/SQL procedure like the following:-
    Code:
    str:=SUBSTR(time,12,2)
    num:=TO_NUMBER(str)
    num:=num-12
    if num>0 then
    Dbms_output.put_line(concat(concat(concat(Concat(to_string(num),':'),'00'),' '),'PM))
    else
    num:= 12+(num)
    Dbms_output.put_line(concat(concat(concat(Concat(to_string(num),':'),'00'),' '),'AM))
    end if
    
     

Share This Page