Home > database > If the string type fields such as REGDATE (8, 20161230) format for '2016-12-30'
If the string type fields such as REGDATE (8, 20161230) format for '2016-12-30'
Time:10-03
In addition to joining together with substr method and direct call is not in a better way
CodePudding user response:
SELECT substr (' 20161230 ', 1, 4) | | '-' | | substr (' 20161230 ', 5, 2) | | '-' | | substr (' 20161230 ', 7, 2) the as REGDATE from dual Such writing is affect efficiency
CodePudding user response:
Expression efficiency of computing is doesn't matter, but the writing is more easy to read, and date value is wrong (such as 20160230) will be an error, kill two birds with one stone,
SELECT TO_CHAR (TO_DATE (' 20161230 ', 'yyyymmdd'), '- dd yyyy - mm) as REGDATE from dual