Convert the Timestamp value to BigInt

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
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Convert the Timestamp value to BigInt

Post by venkates.dw »

Hi,

Can anyone please let me know how to convert the Timestamp value to BigInt. The reson is we are using the MySql as database but we need to store the milli seconds also.

For Ex: 2012-01-04 11:12:13:001 to 20120104111213001

Thanks.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Try using convert() to remove the -,:and the space.
Something like below:

Code: Select all

Convert("-: ","",Timestamp)
If you still face any issue cover the above within AsInteger().
pandeeswaran
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Post by venkates.dw »

while using the convert function, I am not getting the milli seconds into the result value.

For ex: Convert('-:. ','',2012-01-04 15:43:09.989564). I am getting the result as 20120104154309. But i need the result as 20120104154309989564. Please suggest.
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Post by venkates.dw »

while using the convert function, I am not getting the milli seconds into the result value.

For ex: Convert('-:. ','',2012-01-04 15:43:09.989564). I am getting the result as 20120104154309. But i need the result as 20120104154309989564. Please suggest.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Can you check whether your time stamp value has the milli seconds?
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is the Scale value in the metadata set to 6?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Post by venkates.dw »

pandeesh wrote:Can you check whether your time stamp value has the milli seconds?
.

Yes. the timestamp value is having the milli seconds.
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Post by venkates.dw »

ray.wurlod wrote:Is the Scale value in the metadata set to 6? ...
.

For the BigInt do we need to mentioned the scale value?
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

No he asked about the timestamp data type.
pandeeswaran
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Post by venkates.dw »

Ok.

The CurrentTimestampMS() function will return the dateTime along with milli seconds. ( ex: 2012-01-04 16:35:00.189089). I want to store this value as 20120104163500189089 in database ( field datatype is BigInt). Please let me know how i can implement this.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

You have been given a solution already within this thread using Convert() to remove the punctuation from your (character) timestamp. Once converted you simply place it into a BigInt column.

Keep in mind that the maximum value an unsigned BigInt (64-bit integer) can represent is 18,446,744,073,709,551,615. This is 20 digits and would equate to 1844-67-44 07:37:09.551615 when reformatted to YYYY-MM-DD HH:NN:SS.SSSSSS. A signed BigInt could represent a maximum (positive or negative) value of half the unsigned maximum value, 19 digits in length.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Post by venkates.dw »

Thanks. But it is loading into the mysql database as "9223372036854775807" ( some unknown value). While populating into the with Varchar datatype is populating corretly, but the same value while populating into the BigInt column some unknown value is populating.
venkates.dw
Participant
Posts: 67
Joined: Mon Dec 22, 2008 4:07 am

Post by venkates.dw »

Thanks. I am able to store the value in BigInt filed with 5 digit milli seconds.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

That "some unknown value" is the maximum positive value that can be represented by a signed BigInt.
<a href="http://en.wikipedia.org/wiki/Integer_(c ... cience)</a>
- james wiles


All generalizations are false, including this one - Mark Twain.
Post Reply