View previous topic :: View next topic
|
Author |
Message |
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
The below sql expression will return a Timestamp column as a pure numeric value ie. no dashes or periods. Is there an simplier way of doing this?
REPLACE(REPLACE(CHAR(timestamp_column), '-', ''), '.', '') |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
though the data is all numbers, without a CAST, it is still CHAR datatype. |
|
Back to top |
|
|
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
Unfortunately we are still using version 8 of DB2. It has the VARCHAR_FORMAT function but allows for only one string value 'YYYY-MM-DD HH24:MI:SS' which is silly. I guess I have to wait until we upgrade
FYI - I was looking for a CHAR format but with just numbers |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Code: |
(timestamp_column + 1 year + 1 month + 1 day - '0001-01-01-00.00.00.000000') |
You may have to change the format of the literal depending on your default date format. |
|
Back to top |
|
|
|