重庆思庄Oracle、Redhat认证学习论坛
标题:
sqlserver与oracle取年月日的差别
[打印本页]
作者:
anysql
时间:
2017-5-4 10:51
标题:
sqlserver与oracle取年月日的差别
在oracle中取年月日,一般适用to_char,或者extract来完成,比如:
SQL> select extract(year from sysdate) from dual;
EXTRACT(YEARFROMSYSDATE)
------------------------
2017
SQL> select extract(month from sysdate) from dual;
EXTRACT(MONTHFROMSYSDATE)
-------------------------
5
SQL> select extract(day from sysdate) from dual;
EXTRACT(DAYFROMSYSDATE)
-----------------------
4
SQL> select to_char(sysdate,'yyyy') from dual;
TO_C
----
2017
SQL>
但在sqlserver中,有专门的函数来处理年月日;
select year(GETDATE())
2017
select month(GETDATE())
5
select day(GETDATE())
4
欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/)
Powered by Discuz! X3.2