首页 > 数据库    日期:2021-05-28 / 浏览

1.获取系统当前时间
SQL Server 2005:
select getdate()
Oracle:
select sysdate from dual
2.获取年月日
SQL Server 2005:
复制代码 代码如下:
select year(getdate()) --2011
select month(getdate()) --3
select day(getdate()) --23

Oracle:
复制代码 代码如下:
select to_char(sysdate,'yyyy') from dual --2011
select to_char(sysdate,'mm') from dual --03
select to_char(sysdate,'dd') from dual --23
q 季度
hh 小时(12)
hh24 小时(24)
mi 分
ss 秒
D 周中的星期几

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章