0% found this document useful (0 votes)
12 views

Fdmsprac 5

Uploaded by

codewithsam21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Fdmsprac 5

Uploaded by

codewithsam21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

NAME: KADRI AYESHA RAFIQ AHMED

ROLL NO: 24BIT03


CLASS: FY BSCIT
SUBJECT: FDMS
PRACTICAL NO : 5
Queries involving
 Date Functions:
1) NOW(): Give the current system's date and time.

2) CURDATE(): Give the current system's date.

3) CURTIME(): Give the current system's time.

4) DATE(): Extract the date from the DATETIME datatype column.


Query to display the date from the given date and time, i.e., 2021-10-24 18:28:44:

Query to display all the details from the student table with the date:

5) EXTRACT(): Extract a specific part of date and time according to our


requirements: day, month, year, day, hour, minute, etc.

 Query to display the year from the given date, i.e., 24th October 2021.

 Query to display the month from the given date, i.e., 24th October 2021.
 Query to display the day from the given date, i.e., 24th October 2021.

 Query to display the hour from the given time, i.e., 19:10:43.

 Query to display the minute from the given time, i.e., 19:10:43.

 Query to display the seconds from the given time, i.e., 19:10:43.
6) DATE_ADD(): Using the DATE_ADD () function in SQL, we can add a
specific time interval to the given date.
 Query to add an interval of 15 days to the given date, i.e., 15 th jan, 2000.

 Query to add an interval of 15 months to the given date, i.e., 15th jan,
2000.

 Query to add an interval of 15 years to the given date, i.e., 15th jan,

2000.

7) DATE_SUB(): Using the DATE_SUB () function in SQL, we can remove a


specific time interval from the given date.
 Query to remove an interval of 25 years from the given date, i.e., 24th October, 2021.

 Query to remove an interval of 25 months from the given date, i.e., 24 th


October,2021.

 Quer
y to

remove an interval of 25 days from the given date, i.e., 24th October, 2021.

8) DATE_DIFF(): Using the DATEDIFF() function in SQL will give us the


number of days that fall between the two given dates.
 SELECT DATEDIFF("2021-10-24","2021-10-09") AS NEW_DATE;
 SELECT DATEDIFF ("2001-06-30", "1999-11-01") AS NEW_DATE from Students;
9) DATE_FORMAT(): Using the DATE_FORMAT () function in SQL, we can
display the date or time-related information in a well-formatted manner.
 Query to display the given date in a well-formatted manner, i.e., 24th
October, 2021.

 Query to display the given date and time in a well-formatted manner, i.e.,
24th October, 2021 22:30:17.

 Query to display all the details from the student column with the DateTime
column in a well-formatted manner.
 STRING FUNCTIONS:
1) ASCII String Function: This function in SQL returns the ASCII value of the
character in the output.

2) CHAR_LENGTH String Function: This string function returns the length of


the specified word.
3) CONCAT String Function: This string function concatenates two strings or words
and forms a new string in the result.

4) LOWER String Function: This string function allows users to convert the specified
string into lower case letters.
5) UPPER String Function: This string function allows users to convert the
specified string into the UPPER case letters.
 MATH FUNCTIONS:
1)ABS() Function:
The ABS() method returns the absolute value of the number specified.

2) CEILING() Function
The smallest integer value greater than or equal to a given number is returned by
the CEILING() function.
3) SQRT() Function :
Return the square root of a number

4) TRUNCATE:
The TRUNCATE TABLE command deletes the data inside a table, but not the table
itself.

5) POWER:
The POWER() function returns the value of a number raised to the power of another
number.
6) MOD:
The MOD() function returns the remainder of a number divided by another
number.

7) FLOOR:
The FLOOR() function returns the largest integer value that is smaller than or
equal to a number.

8) ROUND:

You might also like