4.2.1.5 Date Functions
Date Functions
MONTHS_BETWEEN(date1, date2)
ADD_MONTHS(date, no. of months)
SYSDATE
Returns system date.
SELECT ord#,
MONTHS_BETWEEN(SYSDATE,orddate)
FROM ord_aug;
Query 27 - Result:
Ord# | MONTHS_BETWEEN(SYSDATE,OrdDate) |
101 | 4.92190562 |
102 | 4.63158303 |
103 | 4.30900239 |
104 | 4.08319594 |
105 | 4 |
SELECT TO_CHAR(orddate,' DD/MM/YYYY') <--- FROM ord_aug; | Converts the value of the date field orddate to character string of the format DD/MM/YYYY |
Query 28 - Result:
TO_CHAR(OrdDate,'DD/MM/YYYY') |
02/08/1994 |
11/08/1994 |
21/08/1994 |
28/08/1994 |
30/08/1994 |
Note:
DD - day of month (1-31)
D - day of week (1-7)
DAY - name of day
MM - month (01-12)
MONTH - name of month
MON - abbreviated name of month
HH:MI:SS - hours:minutes:seconds
fm - fill mode : suppress blank padding
Leave a Comment