dbTalk Databases Forums  

Convert Bigint to DateTime

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Convert Bigint to DateTime in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
robie
 
Posts: n/a

Default Convert Bigint to DateTime - 02-10-2011 , 02:32 AM






I have a column in my database named signup_date with a datatype of
bigint. I want to know how to convert this bigint into datetime
correctly as a result of a sql query.

My sql query is this

SELECT FROM_UNIXTIME(LEFT(signup_date, LENGTH(signup_date) - 3)) AS
date_mili, users_id FROM users WHERE users_id = 210693

Signup_date = 1163609047
But results is 1970-01-14 19:13:29

Thanks for the help!

-robi

Reply With Quote
  #2  
Old   
Luuk
 
Posts: n/a

Default Re: Convert Bigint to DateTime - 02-10-2011 , 03:29 AM






On 10-02-11 09:32, robie wrote:
Quote:
I have a column in my database named signup_date with a datatype of
bigint. I want to know how to convert this bigint into datetime
correctly as a result of a sql query.

My sql query is this

SELECT FROM_UNIXTIME(LEFT(signup_date, LENGTH(signup_date) - 3)) AS
date_mili, users_id FROM users WHERE users_id = 210693

Signup_date = 1163609047
But results is 1970-01-14 19:13:29

Thanks for the help!

-robi
"DB2 Basics: Fun with Dates and Times"
http://www.ibm.com/developerworks/da.../0211yip3.html

If that page does not help, could you post some values, and the date
that is should be ?

SELECT BIGINT(CURRENT TIMESTAMP) FROM sysibm.sysdummy1
20110210102808

--
Luuk

Reply With Quote
  #3  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: Convert Bigint to DateTime - 02-10-2011 , 03:37 AM



On 2011-02-10 09:32, robie wrote:
Quote:
I have a column in my database named signup_date with a datatype of
bigint. I want to know how to convert this bigint into datetime
correctly as a result of a sql query.

My sql query is this

SELECT FROM_UNIXTIME(LEFT(signup_date, LENGTH(signup_date) - 3)) AS
date_mili, users_id FROM users WHERE users_id = 210693

Signup_date = 1163609047
But results is 1970-01-14 19:13:29

Thanks for the help!

Assuming signupd_date is seconds since 1970

db2 "values cast('1970-01-01-00.00.00.0' as timestamp) + 1163609047 seconds"

1
--------------------------
2006-11-15-16.44.07.000000

1 record(s) selected.


/Lennart

Reply With Quote
  #4  
Old   
sanjay kumar
 
Posts: n/a

Default Re: Convert Bigint to DateTime - 02-10-2011 , 06:53 AM



To answer this question, you first need to tell us what signup_date is having. Is it julian day (doesn't look like) or seconds past first julian day?

Submitted via EggHeadCafe
SQL Operations on a Text File with ADO.NET
http://www.eggheadcafe.com/tutorials...th-adonet.aspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.