0

I have a INSERT + SELECT statement. One column is a VARCHAR but must be filled with a date with 'yyyyMMdd' format in 3 different dialect.

With SQL server and Oracle there's no problem, but in Db2 I didn't find anything to do this stuff.

In SQLServer is CONVERT(VARCHAR,S.DT_NASCITA,112)

In Oracle is TO_CHAR(S.DT_NASCITA,'YYYYMMDD')

Any1 can help me pls ?

ty in advice !

Stefano R.
  • 321
  • 1
  • 5
  • 18
  • ...you shouldn't be storing a date formatted as text in the first place, if you can help it. You _especially_ shouldn't be storing multiple values in the same column, or storing multiple formats in the same column. Why are you trying to do this? – Clockwork-Muse Feb 13 '15 at 14:31
  • 'couse I have to. this is a landing table that must cointain data from flat file and for that reason all fileds are VARCHAR. In this case I'm creating some "fake" record using another table, but in this case, the field is in correct type ( exactly date ) – Stefano R. Feb 13 '15 at 14:54

1 Answers1

0

Fix in a very bad way. This way work in all distro, seems

SELECT SUBSTR(CHAR(CURRENT DATE, ISO),1,4) || SUBSTR(CHAR(CURRENT DATE, ISO),6,2) || SUBSTR(CHAR(CURRENT DATE, ISO),9,2) FROM SYSIBM.SYSDUMMY1
Stefano R.
  • 321
  • 1
  • 5
  • 18