Thursday, April 9, 2009

Fiddling with DATES

1. Selecting current date
SELECT SYSDATE FROM DUAL;

2. Adds one day to current date
SELECT SYSDATE+1 FROM DUAL;

3. Adding months
SELECT ADD_MONTHS(SYSDATE,2) FROM DUAL;

4. TRUNC
It truncates the time part from the date TRUNC(SYSDATE).

5. MONTHS_BETWEEN( date1, date2 )
Gives the number of months between two dates.

1 comment:

  1. well is there any way i can store the date that is indicated from the user's timezone, for i am facing a problem, the dates that come are set to server's time zone

    i know the time zone of the user, but what should i add to get the correct date

    though this comment might be out of the scope of your post but your help will be highly appreciated

    ReplyDelete