Dhruv RDBMS PRACTICAL 4
Dhruv RDBMS PRACTICAL 4
PRACTICAL NO: 04
AIM: Implement SQL queries using Date functions like add months,
months-between, round, nextday, truncate, greatest, newtime etc
[ 02 – Hours ]
TRUNCATE
Arguments
1) date
The date argument is a DATE value or an expression that evaluates
to a DATE value that will be truncated.
2) format
The format argument determines the unit to which the date will be truncated.
EXAMPLES
17-OCT-2023 11:01:40
SELECT TO_CHAR(
result
FROM
STUD7124;
OUTPUT:
Second, the TRUNC() function truncated the date. Because we did not pass
the format argument, the TRUNC() function uses the default value that
truncates the date to midnight.
Third, the TO_CHAR() function formatted the result of the TRUNC() function.
The following statement returns the first day of the current month.
SELECT
FROM
STUD7124;
If you want to return the first day of the month of a specific date, you just
need to use that date instead of the SYSDATE
FROM STUD7124;
Output: