当前位置:Gxlcms > 数据库问题 > ORACLE相关函数使用总结

ORACLE相关函数使用总结

时间:2021-07-01 10:21:17 帮助过:16人阅读

1. 2018年12月12日 12时12分  这种时间格式怎么转成2018-12-12 12:12  解决: select regexp_replace(regexp_replace(‘2009年6月28日 12时10分‘, ‘[年]|[月]|[时]‘, ‘-‘),‘[日]|[分]‘,‘‘) as aa from dual 2.获取两个日期直接的年数

select trunc(months_between(to_date(‘2018-10-18 00:00:00‘,‘yyyy-MM-dd hh24:mi:ss‘),to_date(‘2013-09-18 00:00:00‘, ‘yyyy-MM-dd hh24:mi:ss‘)) / 12) as NL from dual

备注:months_between获取两个日子直接的月数,月数除以12即是年,trunc函数截取时不进行四舍五入,

TRUNC(number,num_digits) 

Number 需要截尾取整的数字。 

Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。

ORACLE相关函数使用总结

标签:its   指定   12月   相关   to_date   div   str   ber   bsp   

人气教程排行