plsql - How to keep the military format when converting string to timestap in Oracle? -


this code:

 l_ts := to_timestamp((d || ' 13:00:00'), 'dd.mm.yyyy:hh24:mi:ss');   u_ts := to_timestamp((d || ' 17:00:00'), 'dd.mm.yyyy:hh24:mi:ss'); 

i keep getting:

26-may-13 01.00.00.000000 pm 26-may-13 05.00.00.000000 pm 

i want:

26-may-13 13.00.00.000000 pm 26-may-13 17.00.00.000000 pm 

i.e. 13 , 17 instead of 1 , 5.

thanks hrlping

you converting string date, , display date directly. when way, output formatted string internally , depends on session locale settings.

if want date in format want, should use to_char function format date string when need displayed user. to_char can use format models date in format wish (try in sql server... ;).

consider script:

set serveroutput on; declare      l_ts timestamp; begin     -- here date string     l_ts := to_timestamp(('01.01.2013' || ' 13:00:00'), 'dd.mm.yyyy:hh24:mi:ss');      -- here string representation of date.      -- representation depends on session settings,      -- , should not relayed upon.     dbms_output.put_line(l_ts);     -- examples how can display date string in way need     dbms_output.put_line(to_char(l_ts,'yyyy-mm-dd hh24:mi:ss'));     dbms_output.put_line(to_char(l_ts,'yyyy-mm-dd hh12:mi:ss am')); end; 

hope clear issue. :)


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -