[Oracle]常用日期取值方法

select
  sysdate,
  to_number(to_char(sysdate,'hh24')) 时,
  to_number(to_char(sysdate,'mi'))   分,
  to_number(to_char(sysdate,'ss'))   秒,
  to_number(to_char(sysdate,'dd'))   日,
  to_number(to_char(sysdate,'mm'))   月,
  to_number(to_char(sysdate,'yyyy')) 年,
  to_number(to_char(sysdate,'ddd'))  年内第几天,
  trunc(sysdate,'dd')                一天之始,
  trunc(sysdate,'day')               周初,
  trunc(sysdate,'mm')                月初,
  last_day(sysdate)                  月末,
  add_months(trunc(sysdate,'mm'),1)  下月初,
  trunc(sysdate,'yy')                年初,
  to_char(sysdate,'day')             周几,
  to_char(sysdate,'month')           月份
from
  dual;

------------------------------------------------

SYSDATE    2015-12-09 10:49:51
时         10
分         49
秒         51
日         9
月         12
年         2015
年内第几天  343
一天之始    2015-12-09
周初       2015-12-06
月初       2015-12-01
月末       2015-12-31 10:49:51
下月初     2016-01-01
年初       2015-01-01
周几       星期三
月份       12月
请使用浏览器的分享功能分享到微信等