LINUX.ORG.RU

$ echo "select add_months(to_date('29.06.2007','dd.mm.yyyy'),-6) from dual;" | sqlplus scott/tiger

SQL*Plus: Release 9.2.0.6.0 - Production on Tue Jul 1 14:27:08 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production

SQL>
ADD_MONTH
---------
29-DEC-06

SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production

Deleted
()

> Subtracting six months from June 29, 2007 gives you...February 29, 2007, a day that never existed. In fact, because it never existed, Oracle throws an error if you do that. Other databases just give you February 28 (or March 1 if you're adding, I think).

29 июня 2007 года - 6 месяцев != 29 февраля 2007

Скорее так:
29 июня 2007 года - 4 месяца == 29 февраля 2007

Igron ★★★★★
()

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Jul 1 15:33:06 2008

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select add_months(to_date('29.06.2007','dd.mm.yyyy'),-4) from dual;

ADD_MONTHS
----------
28.02.2007

SQL>

zaharov
()

SQL*Plus: Release 8.1.7.0.0 - Production on Tue Jul 1 17:40:36 2008

(c) Copyright 2000 Oracle Corporation. All rights reserved.

Connected.

ADD_MONT -------- 28.02.07

IMHO инфологемма ...

robot12 ★★★★★
()
Ответ на: комментарий от robot12

Subtracting one month from March 29, 2007 gives you...February 29, 2007, a day that never existed. In fact, because it never existed, Oracle throws an error if you do that. Other databases just give you February 28 (or March 1 if you're adding, I think).

cobold ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.