9 个解决方案
#1
这还不简单:
select to_char(getdate(),'YYYY') + '-12-31 23:59:59' from dual;
select to_char(getdate(),'YYYY') + '-01-01 00:00:00' from dual;
select to_char(getdate(),'YYYY') + '-12-31 23:59:59' from dual;
select to_char(getdate(),'YYYY') + '-01-01 00:00:00' from dual;
#2
1* select to_char(trunc(sysdate,'year'),'yyyy-mm-dd hh24:mi:ss') from dual
SQL> /
TO_CHAR(TRUNC(SYSDA
-------------------
2010-01-01 00:00:00
#3
SQL> select trunc(sysdate),add_months(trunc(sysdate)-1/24/60/60,12) from dual;
TRUNC(SYSDATE) ADD_MONTHS(TRUNC(SYSDATE)-1/24
-------------- ------------------------------
2010-11-4 2011-11-3 23:59:59
SQL>
#4
语句不符合oracle的
SQL> select to_char(sysdate,'yyyy')||'-12-31 23:59:59' from dual;
TO_CHAR(SYSDATE,'YY
-------------------
2010-12-31 23:59:59
SQL> select to_char(sysdate,'yyyy')||'01-01 00:00:00' from dual;
TO_CHAR(SYSDATE,'Y
------------------
201001-01 00:00:00
#5
1楼按照sql server的习惯了。
oracle 如下:
select to_char(sysdate,'YYYY') || '-12-31 23:59:59' from dual
TO_CHAR(SYSDATE,'YYYY')||'-12-
------------------------------
2010-12-31 23:59:59
1 row selected
select to_char(sysdate,'YYYY') || '-01-01 00:00:00' from dual
TO_CHAR(SYSDATE,'YYYY')||'-01-
------------------------------
2010-01-01 00:00:00
1 row selected
#6
刚写完就发现你的了。
#7
呵呵,还是你提供的思想好啊,高手就是高手 要的就是思想
#8
SELECT Add_Months(Trunc(SYSDATE,'yyyy'),12)-1/24/60/60 本年最后一秒 ,
Trunc(SYSDATE,'yyyy') 本年第一天0时0分0秒
FROM dual;
本年最后一秒 本年第一天0时0分0秒
------------------------------------------------------
2010.12.31 23:59:59 2010.01.01 00:00:00
#9
select
trunc(sysdate,'yyyy'),
ADD_MONTHS( trunc(sysdate,'yyyy'),12 )
from dual
#1
这还不简单:
select to_char(getdate(),'YYYY') + '-12-31 23:59:59' from dual;
select to_char(getdate(),'YYYY') + '-01-01 00:00:00' from dual;
select to_char(getdate(),'YYYY') + '-12-31 23:59:59' from dual;
select to_char(getdate(),'YYYY') + '-01-01 00:00:00' from dual;
#2
1* select to_char(trunc(sysdate,'year'),'yyyy-mm-dd hh24:mi:ss') from dual
SQL> /
TO_CHAR(TRUNC(SYSDA
-------------------
2010-01-01 00:00:00
#3
SQL> select trunc(sysdate),add_months(trunc(sysdate)-1/24/60/60,12) from dual;
TRUNC(SYSDATE) ADD_MONTHS(TRUNC(SYSDATE)-1/24
-------------- ------------------------------
2010-11-4 2011-11-3 23:59:59
SQL>
#4
语句不符合oracle的
SQL> select to_char(sysdate,'yyyy')||'-12-31 23:59:59' from dual;
TO_CHAR(SYSDATE,'YY
-------------------
2010-12-31 23:59:59
SQL> select to_char(sysdate,'yyyy')||'01-01 00:00:00' from dual;
TO_CHAR(SYSDATE,'Y
------------------
201001-01 00:00:00
#5
1楼按照sql server的习惯了。
oracle 如下:
select to_char(sysdate,'YYYY') || '-12-31 23:59:59' from dual
TO_CHAR(SYSDATE,'YYYY')||'-12-
------------------------------
2010-12-31 23:59:59
1 row selected
select to_char(sysdate,'YYYY') || '-01-01 00:00:00' from dual
TO_CHAR(SYSDATE,'YYYY')||'-01-
------------------------------
2010-01-01 00:00:00
1 row selected
#6
刚写完就发现你的了。
#7
呵呵,还是你提供的思想好啊,高手就是高手 要的就是思想
#8
SELECT Add_Months(Trunc(SYSDATE,'yyyy'),12)-1/24/60/60 本年最后一秒 ,
Trunc(SYSDATE,'yyyy') 本年第一天0时0分0秒
FROM dual;
本年最后一秒 本年第一天0时0分0秒
------------------------------------------------------
2010.12.31 23:59:59 2010.01.01 00:00:00
#9
select
trunc(sysdate,'yyyy'),
ADD_MONTHS( trunc(sysdate,'yyyy'),12 )
from dual