Timestamp format- 24 hrs to 12 hrs

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ajithaselvan
Participant
Posts: 75
Joined: Mon Jul 12, 2010 4:11 am
Location: Chennai

Timestamp format- 24 hrs to 12 hrs

Post 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,
Ajitha S
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ajithaselvan
Participant
Posts: 75
Joined: Mon Jul 12, 2010 4:11 am
Location: Chennai

Post 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,
Ajitha S
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post 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,
- james wiles


All generalizations are false, including this one - Mark Twain.
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post 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
Cheers
Ravi K
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post 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).
Cheers
Ravi K
Post Reply