sysdate [message #201268] |
Fri, 03 November 2006 06:13 |
webadministrator
Messages: 45 Registered: October 2005
|
Member |
|
|
hello,
if i want to do a query that selects all the companies that are aged less than 1 year, how can this be done? should i use sysdate? i.e select count(*) from company where date_founded < (sysdate - ...)
thank you.
|
|
|
|
Re: sysdate [message #201274 is a reply to message #201268] |
Fri, 03 November 2006 06:26 |
webadministrator
Messages: 45 Registered: October 2005
|
Member |
|
|
does it work if i want to compare date_founded to another date say: date2.
where date_founded > add_months(date2, -12)
thank you very much.
|
|
|
|
Re: sysdate [message #201290 is a reply to message #201281] |
Fri, 03 November 2006 07:06 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
SYSDATE is just another date, just like 'date2'. However, perhaps you should pay attention to (possible) difficulties if you rely on currently set NLS_DATE_FORMAT (which might change on another database, or even on this one).
Therefore, don't write something like thisWHERE date_founded > '03.11.2006' (which, actually, might work at the moment), but rather use TO_DATE function, asWHERE date_founded > TO_DATE('03.11.2006', 'dd.mm.yyyy')
|
|
|