Varchar to timestamp

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
anudeepdasari001
Participant
Posts: 58
Joined: Mon Dec 14, 2015 3:16 pm
Location: Arizona

Varchar to timestamp

Post by anudeepdasari001 »

Source 99999999-83885269=16:11:4730 timestamp value(timestamp varchar type),, What is the way to convert it into target(datatype timestamp),,please provide valid answers and help me out
anudpETL
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.
What do the two source numbers represent?
What (precisely) are you trying to achieve? (Hint: "16:11:4730" is not a timestamp.)

We could guess your requirement, but that would waste everyone's time were the guess incorrect.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Varchar to timestamp

Post by ray.wurlod »

anudeepdasari001 wrote:...help me out
Groucho Marx wrote:I'd love to help you out. Which way did you come in?
:lol:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
anudeepdasari001
Participant
Posts: 58
Joined: Mon Dec 14, 2015 3:16 pm
Location: Arizona

Post by anudeepdasari001 »

99999999(Said by businees to subract the value with 99999999 to get timestamp)-83885269(format we get in the source)=16:11:4730
anudpETL
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

We got that.

99999999 - 83885269 =16114730

However, as Ray noted, that is not a timestamp. Time perhaps or a duration, but timestamp no. What do you need to do with it, where / how will it be stored? Guessing when you show it as "16:11:4730" that means minutes, seconds and milliseconds? Please confirm / deny and give us more in the way of details so we can provide some cogent help.
-craig

"You can never have too many knives" -- Logan Nine Fingers
anudeepdasari001
Participant
Posts: 58
Joined: Mon Dec 14, 2015 3:16 pm
Location: Arizona

Post by anudeepdasari001 »

This is what the requirement in the mapping document

99999999 - DN_TIME_STAMP = Date (example: 99999999 - 83885269 = 16114730 (16:11:4730))

Source DN_Time_Stamp Datatype=varchar
target column datatype=timestamp


what is the way to do that,,Any suggestions welcome
anudpETL
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Suggest you read my reply that you probably just missed. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
anudeepdasari001
Participant
Posts: 58
Joined: Mon Dec 14, 2015 3:16 pm
Location: Arizona

Post by anudeepdasari001 »

hello chulett,

I am thinking those are hours,minutes and mill seconds,What you want me to know from business
anudpETL
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Probably stating the obvious here, but 16114730 milliseconds does not equate to 16:11:4730 (as hh:mm:nnnn)

I would be going back to whomever provided you the spec and get clarification.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I just meant the bit after the last colon were the milliseconds... but yes, let's not say what we're thinking it is - get all of us some clarification. :wink:

And just want to re-emphasis the fact that the data you are showing us is not a timestamp, that would require a full date and time component. If you actually do need to build a timestamp from this you'll need to get the business requirements with the exact 'how' it should be built, date to use, etc.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Benz
Participant
Posts: 3
Joined: Wed Feb 17, 2016 6:07 am
Location: Bangalore

Post by Benz »

I think you just want to subtract your column value from 99999999 and then insert ":" as you have shown in the above example.

Lets say that you have a value "83885269" DN_TIME_STAMP column. In transformer give a derivation something like this in a stage variable., say SV

99999999 - DN_TIME_STAMP => SV value would be 16114730

Then in the output column derivation give it as SV[1,2]:':':SV[3,4]:':':SV[5,8] which would result in 16:11:4730

Again it wont be a timestamp format. So, your target column cannot be timestamp. But still you can get the output by setting it as varchar and validate the same.
Benjamin
Post Reply