Edited PR-4
Edited PR-4
Date: _________________
Practical No.4: In-built Functions (Part – 1)
a. Write SQL queries to use various date functions.
b. Write SQL queries to use various numeric functions
A. Objective:
To proficiently use SQL queries with various date functions and numeric
functions to effectively manipulate and analyse date-related and numeric data in the
database.
41 | P a g e 236120316032
Database Management (4331603)
1) Skill in using advanced numeric functions such as POWER, SQRT, LOG, and
TRUNC to perform complex calculations and generate insights from numerical
data.
E. Practical Outcome(PRo)
Students will be able to understand and use various date and numeric function.
G. Prerequisite Theory:
Numeric Function :-
1. ABS() : Returns the absolute value of numeric expression.
2. ACOS(): Returns the arccosine of numeric expression. Returns NULL if the value is
not in the range -1 to 1.
3. ASIN() : Returns the arcsine of numeric expression. Returns NULL if value is not in
the range -1 to 1
4. ATAN() : Returns the arctangent of numeric expression.
5. ATN2() : Returns the arctangent of the two variables passed to it.
6. CEILING() : Returns the smallest (closest to negative infinity) integer value that is
greater than or equal to this value.
7. COS() : Returns the trigonometric cosine of the given value.
8. COT() : Returns the trigonometric cotangent of the given value.
9. DEGREES() : Returns numeric expression converted from radians to degrees.
10. EXP() : Returns the base of the natural logarithm (e) raised to the power of passed
numeric expression.
11. FLOOR() : Returns the largest integer value that is not greater than passed numeric
expression.
42 | P a g e 236120316032
Database Management (4331603)
12. LOG() : Returns the natural logarithm of the passed numeric expression.
13. LOG10() : Returns the base-10 logarithm of the passed numeric expression.
14. PI() : Returns the value of pi
15. POWER() : Returns the value of one expression raised to the power of another
expression
16. RADIANS() : Returns the value of passed expression converted from degrees to
radians.
17. RAND() : Returns the random value between 0 and 1.
18. ROUND() : Returns numeric expression rounded to an integer. Can be used to
round an expression to a number of decimal points
19. SIGN() : Returns the sign of a number, indicating whether it is positive, negative, or
zero.
20. SIN() : Returns the sine of numeric expression given in radians.
21. SQRT() : Returns the non-negative square root of numeric expression.
22. TAN() : Returns the tangent of numeric expression expressed in radians.
Date Function :
1. ADDDATE(): It returns a date after a certain time/date interval has been added.
2. ADDTIME(): It returns a time / date time after a certain time interval has been
added.
3. CURDATE(): It returns the current date.
4. CURRENT_DATE(): It returns the current date.
5. CURRENT_TIME(): It returns the current time.
6. CURRENT_TIMESTAMP(): It returns the current date and time.
7. CURTIME(): It returns the current time.
8. DATE(): It extracts the date value from a date or date time expression.
9. DATEDIFF(): It returns the difference in days between two date values.
10. DATE_ADD(): It returns a date after a certain time/date interval has been added.
11. DATE_FORMAT(): It formats a date as specified by a format mask.
43 | P a g e 236120316032
Database Management (4331603)
12. DATE_SUB(): It returns a date after a certain time/date interval has been
subtracted.
13. DAY(): It returns the day portion of a date value.
14. DAYNAME(): It returns the weekday name for a date.
15. DAYOFMONTH(): It returns the day portion of a date value.
16. DAYWEEK(): It returns the weekday index for a date value.
17. DAYOFYEAR(): It returns the day of the year for a date value.
18. EXTRACT(): It extracts parts from a date.
19. FROM_DAYS(): It returns a date value from a numeric representation of the day.
20. HOUR(): It returns the hour portion of a date value.
21. LAST_DAY(): It returns the last day of the month for a given date.
22. LOCALTIME(): It returns the current date and time.
23. LOCALTIMESTAMP(): It returns the current date and time.
24. MAKEDATE(): It returns the date for a certain year and day-of-year value.
25. MAKETIME(): It returns the time for a certain hour, minute, second combination.
H. Resources/Equipment Required
Sr. Instrument/Equipment/
Specification Quantity
No. Components/Trainer kit
Computer (i3-i5 preferable), RAM
1 Hardware: Computer System
minimum 2 GB and onwards
As Per
2 Operating System Windows/ Linux/ MAC
Batch
3 Software Oracle Size
J. Source code:
44 | P a g e 236120316032
Database Management (4331603)
(d) If the date is 31-jul-13 then find out the date of friendship day.
45 | P a g e 236120316032
Database Management (4331603)
46 | P a g e 236120316032
Database Management (4331603)
2) Which SQL function can be used to add or subtract a specified interval of time
from a given date?
a) DATEDIFF ✓ b) DATEADD
c) DATEPART d) DATETIME
3) Which Oracle numeric function can be used to calculate the absolute value of a
number?
A) ROUND B) CEIL
✓ B) ABS D) MOD
L. References / Suggestions
1) https://www.w3schools.com/sql/default.asp
2) https://www.tutorialspoint.com/dbms/
3) https://www.geeksforgeeks.org/dbms/
47 | P a g e 236120316032
Database Management (4331603)
M. Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
48 | P a g e 236120316032