date problem

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

Post Reply
mohandl
Participant
Posts: 43
Joined: Tue Dec 26, 2006 7:01 am
Location: pune

date problem

Post by mohandl »

Hi all,

My source is text file having one column date value is "1/28/2008 1:46:55 PM",this date i have to populate in a SQL server

While loading i am getting error like "1/28/2008 1:46:55 PM is an Invalid date"

Can any one let me know how can i resolve this problem.

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

Post by ray.wurlod »

Change the format to one acceptable to SQL Server, particularly CCYY-MM-DD HH:MM:SS or CCYY-MM-DD HH:MM:SS.sss

Split the input into date and time. Use Iconv() and Oconv() functions to reorganize both, then concatenate with a space between.

Code: Select all

Oconv(Iconv(Field(InLink.TheString," ",1,1),"DMDY"),"D-YMD[4,2,2]") : " " : Oconv(Iconv(Field(InLink.TheString," ",2,2),"MTHS"),"MTS:")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mohandl
Participant
Posts: 43
Joined: Tue Dec 26, 2006 7:01 am
Location: pune

Post by mohandl »

I am able to split date part ,but How to split the time portion
Is there any function to split the time portion.

Regards,
Mohan
MOHAN
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Use a substring expression, in this case the date and time are separated by a " " (space), so the date would be "FIELD(In.Column," ",1)"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

But, because there is a space ahead of your AM/PM designator, you need a variation, as I posted in my original answer, which is a complete solution.

Do purchase premium membership. Revenue from premium membership is totally devoted to helping to defray the hosting and bandwidth costs incurred by DSXchange. And you'll be able to read premium posters' contributions in their entirety.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
deva
Participant
Posts: 104
Joined: Fri Dec 29, 2006 1:54 pm

Post by deva »

ray.wurlod wrote:Change the format to one acceptable to SQL Server, particularly CCYY-MM-DD HH:MM:SS or CCYY-MM-DD HH:MM:SS.sss

Split the input into date and time. Use Iconv() and Oconv() functions to reorganize b ...
Find the date formate in squl server and use the Iconv() and Oconv() functions .

example is Oconv(Iconv(DSLink44.END_DATE[1,10],"D4/"),"D-DMY[,A,]") , go to help and select as per your formate
gsym
Charter Member
Charter Member
Posts: 118
Joined: Thu Feb 02, 2006 3:05 pm

Post by gsym »

Hi,

To split the time part alone as per your Date format, try Right function

Right("1/28/2008 1:46:55 PM",10) will result - 1:46:55 PM

Thanks & Regards - gsym
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

Mohandl,

I had similar requirement and my issue was resolved .Please look at thsi
post .

viewtopic.php?t=107975&highlight=

Thanks
Paddu
There is nothing good or bad, but thinking makes it so. --William Shakespeare
Post Reply