Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2/400 Timestamp (Dash between date & time)

Status
Not open for further replies.

MStarkey

IS-IT--Management
Mar 6, 2003
2
US
We have an application that works with MS SQL. We are converting it to DB2/400. The timestamp format on the AS400 is yyyy-mm-dd-hh.mm.ss.xxxxx. The problem we have is the dash between the dd and the hh. Is there a way to get rid of this using the date/time format selections?
Thanks
 
Try something like:-

SELECT SUBSTR(CHAR(timestamp),1,10)
CONCAT SUBSTR(CHAR(timestamp),12,15)
FROM table_name


Hope that helps


Mick
 
DB2/400's timestamp data type (Z) has that edit mask; I don't think you can get rid of the dash between the date and the time without separating them into date and time fields. Timestamps are not stored internally as a character field - they are stored as binary - the system will show them with the edit mask by default when using SQL.

When processing a timestamp field in a HLL (such as RPG IV or ILE Cobol), you can move them into separate date (type D) and time (type T) fields in just about any format you want.

DbGod's suggestion should work for SQL.
"Don't worry about the world coming to an end today. It's already tomorrow in Australia."
--Charles Schultz

 
Thanks very much. I think we have the issue resolved and you saved us some time. Thanks again.
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top