我有一个页面可以从apex集合中获取数据,其中一个字段是日期,但由于它来自集合,因此它会显示为文本。将它转换为日期的最佳方法是什么?
一般来说,通过应用正确的格式掩码,文本(字符串)将通过TO_DATE函数转换为DATE。例如:
SQL> with test (text_value) as
2 (select '23.04.2019' from dual union all
3 select '04-2019-23' from dual union all
4 select '04 April 2019' from dual
5 )
6 select to_date(text_value, 'dd.mm.yyyy') result from test
7 where text_value = '23.04.2019'
8 union all
9 select to_date(text_value, 'mm-yyyy-dd') from test
10 where text_Value = '04-2019-23'
11 union all
12 select to_date(text_value, 'dd month yyyy', 'nls_date_language=english')
13 from test
14 where text_value = '04 April 2019'
15 /
RESULT
----------
23/04/2019
23/04/2019
04/04/2019
SQL>