oracle截取时间的年/月/日/时/分/秒

修改日期格式为年月日时分秒: alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期转化为年月日时分秒格式
select to_char(sysdate,'yyyy')   nowYear from dual;      //获取时间的年
select to_char(sysdate,'mm')    nowMonth from dual;  //获取时间的月
select to_char(sysdate,'dd')      nowDay from dual;       //获取时间的日
select to_char(sysdate,'hh24')  nowHour from dual;     //获取时间的时
select to_char(sysdate,'mi')      nowMinute from dual;  //获取时间的分
select to_char(sysdate,'ss')       nowSecond from dual;  //获取时间的秒

原文链接:https://blog.csdn.net/seekandfindyou/article/details/80668980

猜你喜欢

转载自www.cnblogs.com/mergy/p/12055055.html