Query Selet Eyame - Ada Mhs Csysoate,) "Thining - Dete",: 0dmolhscsysdate, 42) " Date Altx1 Yea Cometion Paom
Query Selet Eyame - Ada Mhs Csysoate,) "Thining - Dete",: 0dmolhscsysdate, 42) " Date Altx1 Yea Cometion Paom
Practical-5
AIM: Implement SQL queries using Date functions like addmonths,
months-between, round, nextday, truncate.
ADD MONTHS(date,n)
Returns new date after addingn months in the date specified by date.
If n is a negative then month will be subtracted.
Example: SELECT ADD_MONTHS (SYSDATE,3), ADD_MONTHS(SYSDATE<-3) FROM
dual;
OUTPUT:
ADD_MONTH ADD_MONTH
****--- --
30-OCT-17 30-APR-17
Exercise:
(1) Select all the employs along with the one year completion of their job. Joining
date and Date after completion of 1 should be included).
14-SEP- 21 11-SEP-21
MONTHS_BETWEEN(date 1,date2)
Prepared By: D.G. Variya(Lecturer Compuet Dept, SKJP Bharuch)
Lab Manual Database Management System
oUTPUT:
Exercise
(2) Select all the employs along with their age.
EYtmE AeE
Ycel
ShYam
Teoal
Rohan 19
1
LAST DAY(date)
Returns last day of the month specified by date
Exercise
(1) Select the first salary date of all the employs along with name and date of
joining
QUERY SEFT EmE LAST-DAy GYsDAIE), M0 men THSSOETE)
aini ng dte ERn Emtloyec
OUTPUT: (Draw Table)
31H-1
Exercise
(1) The first Sunday of August is celebrated as a Friendship day. Find what will be
the date on that day in year ot 2017
OUTPUT:
MEXTDAYc'3j-JUL -1 7, 'SUxpn)
O-AUGT-17
ROUND(date, format):
Returns the rounded date according to format.
If format is omitted, date is rounded to next day if the time is 12:00 PM or
later
Example: SELECT ROUND(SYSDATE) FROM dual
OUTPUT
ROUND(SYSDATE)
31-JUL-17
Exercise: Try yourself different date formats and observe the output.
TRUNC(date, format)
Returns Truncated date according to format
If format is omitted, date is truncated to 12:00 AM (mid night) ie. very first moment of
the date specified.
Output
TRUNC(SYSDATE)
30-JUL-17
Exercise: Try yourself different date formats and observe the output.
SIGN:
DATE
SKJP Bharuch)
Prepared By: D.G. Variya(Lecturer Compuet Dept,