Assignment 4
Assignment 4
The TO_CHAR function in DBMS is used to convert dates, numbers, or other data types into
a formatted string.
TO_CHAR(value, format_model)
value: The date, number, or other data type you want to convert.
value: This is the numerical value of the time period you want to add or subtract (e.g., 1, 30,
etc.).
unit: This specifies the time unit for the duration (e.g., DAY, HOUR, MINUTE, SECOND,
MONTH, YEAR).
SELECT TO_CHAR(SYSDATE, 'MONTH YYYY') AS "Current Month and Year" FROM DUAL;
Name VARCHAR2(20),
Date_of_Joining DATE
);
COMMIT;
FROM EMP;
FROM EMP
-- 15. Display those employees who join the company this month
-- 16. Display those employees who joined the company in the last 30 days
SELECT Empno, Name, Date_of_Joining FROM EMP WHERE Date_of_Joining BETWEEN
SYSDATE - 30 AND SYSDATE;
Date_of_Departure DATE,
Time_of_Departure TIMESTAMP,
Time_of_Arrival TIMESTAMP
);
COMMIT;
FROM Train;
FROM Train
FROM Train