问题描述
大家好,我的日期格式为2015年12月5日,即dd/mm/yyyy.我需要将其转换为2015年5月12日,即mm/dd/yyyy.谁能给我解决办法.
Hello guys i have a date format of 12/05/2015 i.e., dd/mm/yyyy . I need to convert this as 05/12/2015 i.e., mm/dd/yyyy . Can any one give me a solution .
推荐答案
由于默认情况下函数TO_DATE期望日期作为char值的格式为"MM/DD/YYYY",因此您需要指定要处理的日期格式为"DD/MM/YYYY".然后,您希望最终输出为字符串(大概)为"MM/DD/YYYY"格式,因此您需要功能TO_CHAR.因此,您也必须跳过这一障碍.那么,您的示例的最终声明如下:
Because function TO_DATE by default expects the date as a char value to be in the form 'MM/DD/YYYY', you need to specify you're handing it in as 'DD/MM/YYYY'. Then you want the final output to be a string (presumably) in format 'MM/DD/YYYY', so for that you need the function TO_CHAR. So you have to jump that hurdle, too. The final statement for your example, then, looks like this:
TO_CHAR(TO_DATE('12/05/2015', 'DD/MM/YYYY'), 'MM/DD/YYYY')
输出将为'05/12/2015'.
The output will be '05/12/2015'.
这篇关于INFORMATICA-日期格式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!