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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to join the separated date field

Status
Not open for further replies.

tokita

Programmer
Aug 6, 2001
3
JP
Hi guys,

I'm the begginer of DB2 user.
I have a really simple question, that is about the combinning date fields. There are Year field, Month field, and Day field. All of them are varchar data-types.
Then, I want to combine all of them, and creat the new serialYear type field. So I can put the some dayname thing on the other field as Monday, tuesday, so on.

Please let me know, if you know about this.

Uri
 
You can concatenate them using the CONCAT function or the || operator. For example, to get the date in YYYYMMDD format, do the following:

SELECT YEAR_FIELD||MONTH_FIELD||DAY_FIELD FROM TABLE

An easier way to get a date formatted is to use the CHAR function:

SELECT CHAR(TIME_STAMP, USA) FROM TABLE

Hope that helps.

Regards,
Suresh
 
Thanks a lot, Suresh.
I'll try this way.

uri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top