Page 1 of 1

Timestamp format- 24 hrs to 12 hrs

Posted: Fri Feb 04, 2011 4:49 am
by ajithaselvan
Hi,
Can anyone help me to resolve this?
I'm receiving the timestamp value. It is in format of 24hrs. I need to convert to 12 hrs format.

Eg:Input: 2005-01-01 00:00:00.000000
Output:2005-01-01 12:00:00 AM





Thanks,

Posted: Fri Feb 04, 2011 1:40 pm
by ray.wurlod
First question - are you really receiving timestamps (from a database) or are your receiving strings containing timestamps (from a text file)? Your answer to that question will affect the answer that we can give for your original question.

Posted: Sun Feb 06, 2011 11:22 pm
by ajithaselvan
Yeah. I'm receiving timestamp fom the database.

Note: As I'm not a premium memmber, I'm not able to read your full message.



Regards,

Posted: Mon Feb 07, 2011 12:31 am
by jwiles
I suggest reading the section on Date and Time format strings in the Parallel Job Developer Guide. Specifically, the %H, %HH and %aa options will provide what you are needing.

Regards,

Posted: Mon Feb 07, 2011 3:07 am
by Ravi.K
As you said, your source is Database then you would handle at Source itself. Check for appropriate timestamp mask in Database flavours. For example Refer the below queries (Oralce).

SQL> select sysdate from dual;

SYSDATE
-------------------
2011-02-07 14:32:51

SQL> select to_char(sysdate,'yyyy-mm-dd hh:mi:ss AM') from dual;

TO_CHAR(SYSDATE,'YYYY-
----------------------
2011-02-07 02:32:56 PM

Posted: Mon Feb 07, 2011 7:16 am
by Ravi.K
Or Use appropriate "TYPE CONVERSION" functions(TimestampToString or StringToTimestamp) to get required timestamp format by using format options like %H(12 Hours Clock), %HH(24 Hours Clock) and %aa (Meridian part) options(As suggested by james).