DateTimestamp

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

DateTimestamp

Post by g_rkrish »

hi,

I have job in which i have two columns,one has the date as string and another one has the time stamp alone as string..Is any way can i convert that to date time stamp..For ex

column1:20070809
Column2:061000

ReqdOutput:08/09/2007 06:10:00pm

I tried using the iconv ocnv..also i tried oncat the string and use MTHS option on iconv..the o/p comes empty....

Thanks,
RK
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In a server job just format the concatenation.

Code: Select all

Fmt(col1:col2,"####-##-## ##:##:##")
Not sure how you established that 06 is pm in your example, but ISO 8601 specifies 24 hour clock for a timestamp.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jguerrero
Participant
Posts: 21
Joined: Wed Aug 27, 2003 5:12 pm
Location: Chile -South America
Contact:

Post by jguerrero »

Try this in a routine

D=oconv(iconv(Arg1,"DYMD[4,2,2]"),"D/YMD[4,2,2]")
if Arg2<120000 then
S="AM"
end
else
S="PM"
end
T=Arg2[1,2]:":":Arg2[3,2]:":":Arg2[5,2]
Ans=D:" ":T:S
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Post by g_rkrish »

ray.wurlod wrote:In a server job just format the concatenation.

Code: Select all

Fmt(col1:col2,"####-##-## ##:##:##")
Not sure how you established that 06 is pm in your example, but ISO 8 ...
hi Ray,

I used the code given by you but modified little bit my code is like this...

Fmt(Oconv(Iconv(InDWWORK.DW_ADJ_DATE,"DYMD[4,2,2]"),"D/MDY[2,2,4]"): InDWWORK.DW_ADJ_TIME,"########## ##:##:##")

but when i try to insert into my target databse DB2 it is poping out beacuse it is not time stamp data type...I snay way to convert that to time stamp..I think the Dstranform time stamp is for data to timestamp....

thanks,
RK
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, put the"-" characters into the Fmt mask.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Post by g_rkrish »

ray.wurlod wrote:Yes, put the"-" characters into the Fmt mask. ...
Hi Ray,

I f i give that format am not getting the reqd format where it comes out like 08-/0-7/20-/.....Also i changed the fromat to the one you given it gives the eror in assignment error..what we can do about...Pls help me out....
RK
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Just do some tweaking with the code:

Code: Select all

Fmt(Oconv(Iconv(InDWWORK.DW_ADJ_DATE,"DYMD[4,2,2]"),"DMDY[2,2,4]"): InDWWORK.DW_ADJ_TIME,"##/##/#### ##:##:##") 
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Post by g_rkrish »

us1aslam1us wrote:Just do some tweaking with the code:

Code: Select all

Fmt(Oconv(Iconv(InDWWORK.DW_ADJ_DATE,"DYMD[4,2,2]"),"DMDY[2,2,4]"): InDWWORK.DW_ADJ_TIME,"##/##/#### ##:##:##") 
I tried you code it didnot work am getting the out put like this

07//1/6/20 07:04:31 so what i did was i changed to
Fmt(Oconv(Iconv(InDWWORK.DW_ADJ_DATE,"DYMD[4,2,2]"),"DMDY[2,2,4]"): InDWWORK.DW_ADJ_TIME,"########## ##:##:##")

The out put comes right but the dta type comes as string so when i try to insert am getting the error saying string value assgined to the datetime data type....
RK
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Just try this piece:

Code: Select all

Oconv(Iconv(InDWWORK.DW_ADJ_DATE,"DYMD[4,2,2]"),"D/MDY[2,2,4]"):" ":InDWWORK.DW_ADJ_TIME
Check for the timestamp format at the output, if needed append the milliseconds. Two other things which need to be considered is Null- Handling and Input date format.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Post by g_rkrish »

us1aslam1us wrote:Just try this piece:

Code: Select all

Oconv(Iconv(InDWWORK.DW_ADJ_DATE,"DYMD[4,2,2]"),"D/MDY[2,2,4]"):" ":InDWWORK.DW_ADJ_TIME
Check for the timestamp format at the output, if needed append the milliseconds. Two other things which need to be considered is Null- Handling and Input date format.
It just concats the string with that also it is not the format of timestamp where am getting like 07/16/2007 043146 .
RK
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Sorry its my bad. You can substring the time part and concatenate it.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Post by g_rkrish »

us1aslam1us wrote:Sorry its my bad. You can substring the time part and concatenate it.
will the data type will be Timestamp?......
RK
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please specify EXACTLY what you want to get out, including its data type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Post by g_rkrish »

ray.wurlod wrote:Please specify EXACTLY what you want to get out, including its data type. ...
Here is what i want

column1:20070809 Datatype:Decimal (8) which is CFF source
Column2:061000 Datatype:char(6) ,, ,, ,,,,,,,

ReqdOutput:08/09/2007 06:10:00 am Datatype Timestamp (DB2 database)


Pls let me know if you need any more info.....
RK
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Reorder the date components, and format into a timestamp. Simple string manipulation.

Code: Select all

Col1[5,2] : "/" : Col1[7,2] : "/" : Col1[1,4] : " " : Col2[1,2] : ":" : Col2[3,2] : ":" : Col2[5,2] : " " : (If Col2[1,2] < 12 Then "am" Else "pm")
Still need to learn how you handle times earlier than 1:00 am - you may need to tweak the formula slightly, as well as providing a means to differentiate 12:15am from 12:15pm in your source data.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply