sql - Convert YYYYMMDD to Excel dd/mm/yy -
in this post gert grenander makes suggestion format date field 'yyyy-mm-dd hh:mm:ss'.
how convert 'yyyymmdd' 'dd/mm/yy' in sql call using same method?
select date2, digits(date2), (substr(digits(date2),7,2) concat '/' concat substr(digits(date2),5,2) concat '/' concat substr(digits(date2),3,2) ) mmddyy datesample
gives:
signed char data type digits ( date2 ) mmddyy ---------- ---------------- -------- 20130711 20130711 11/07/13
you'll need convert decimal value (date2) string via digits, use substr extract pieces need, use concat (or ||
) reassemble them including delimiter want. if 'date' column character, can leave out conversion character.
select date4, (substr(date4,7,2) concat '/' concat substr(date4,5,2) concat '/' concat substr(date4,3,2) ) mmddyy datesample
gives:
char char data type mmddyy --------- -------- 20130711 11/07/13
Comments
Post a Comment