DBMSpractical5 (A BC)
DBMSpractical5 (A BC)
DBMSpractical5 (A BC)
5 (A, B & C)
(A)Date Functions:
Table: employees
emp_name VARCHAR(50),
hire_date DATE,
birth_date DATE,
last_promotion_date DATE
);
VALUES
Query:
SELECT CURRENT_DATE;
-- or
SELECT CURDATE();
Query:
SELECT CURRENT_TIME;
-- or
SELECT CURTIME();
Query:
SELECT NOW();
Query:
SELECT DATE(NOW());
5. YEAR(), MONTH(), DAY(): Extracts the year, month, or day from a date.
Query:
FROM employees;
6. HOUR(), MINUTE(), SECOND(): Extracts the hour, minute, or second from a time or
datetime.
Query:
SELECT HOUR(NOW()) AS current_hour, MINUTE(NOW()) AS current_minute,
SECOND(NOW()) AS current_second;
Query:
FROM employees;
Query:
Emp_name VARCHAR(50),
Position VARCHAR(50),
Department VARCHAR(50),
Email VARCHAR(100)
);
Query:
VALUES
Query:
FROM employees1;
Query:
FROM employees1;
Query:
FROM employees1;
Query:
FROM employees1;
5. REPLACE(): Replaces all occurrences of a substring within a string.
Query:
FROM employees1;
Query:
Query:
item VARCHAR(50),
quantity INT,
sale_date DATE
);
Query:
FROM sales;
2. CEIL() / CEILING() and FLOOR(): CEIL() rounds up to the nearest integer, while
FLOOR() rounds down.
Query:
FROM sales;
Query:
FROM sales;
Query:
SELECT sale_id, item, POWER(quantity, 2) AS quantity_squared
FROM sales;
Query:
FROM sales;
Query:
FROM sales;