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
varshanswamy
Participant
Posts: 48 Joined: Thu Mar 11, 2004 10:32 pm
Post
by varshanswamy » Sun Aug 28, 2005 6:03 pm
Hi,
I have input value for date as follows
28/Aug/2005:17:00:07
I need to obtain the following string
2005-08-28 17:00:07
I have used many stage variables to get the above value.
what is the best way to get the above mentioned value.
regards,
varsha
ray.wurlod
Participant
Posts: 54607 Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:
Post
by ray.wurlod » Sun Aug 28, 2005 6:52 pm
Some combination of Date/String conversion functions with appropriate date picture arguments.
Stage variables are OK too; they become local variables in the generated code.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Posts: 5245 Joined: Thu Jun 16, 2005 11:00 pm
Post
by kumar_s » Sun Aug 28, 2005 10:26 pm
Hi,
Is the value of date "28/Aug/2005:17:00:07" in sequential file or in database.
Coz if it is sequential file, you can read it as varchar and so you can avoid a string conversion.
And so you can convert the string to date using funciton.
regards
kumar
info_ds
Charter Member
Posts: 88 Joined: Thu Feb 10, 2005 4:36 am
Location: B\'lore
Post
by info_ds » Mon Aug 29, 2005 1:59 am
hi varsha,
date format as u have mentioned
d1=28/Aug/2005:17:00:07
i tried like this.
DateToString(StringToDate(Left(d1,11),"%dd/%mmm/%yyyy"),"%yyyy-%mm-%dd") : " " : Right(d1,8)
it works fine.
info_ds
Charter Member
Posts: 88 Joined: Thu Feb 10, 2005 4:36 am
Location: B\'lore
Post
by info_ds » Mon Aug 29, 2005 2:07 am
sorry it is
Right(d1,8)
varshanswamy
Participant
Posts: 48 Joined: Thu Mar 11, 2004 10:32 pm
Post
by varshanswamy » Mon Aug 29, 2005 8:54 am
info_ds wrote: hi varsha,
date format as u have mentioned
d1=28/Aug/2005:17:00:07
i tried like this.
DateToString(StringToDate(Left(d1,11),"%dd/%mmm/%yyyy"),"%yyyy-%mm-%dd") : " " : Right(d1,8)
it works fine.
Thankz for the input, the code works.
regards,
varsha