0% found this document useful (0 votes)
14 views2 pages

l226557 Part1

Uploaded by

l226557
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)
14 views2 pages

l226557 Part1

Uploaded by

l226557
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/ 2

Part 1)

Comparing Date data types, related functions, and usage across MySQL, Oracle, and SQL Server involves
understanding their differences and similarities.

Date Data Types:

1. MySQL:

 DATE: Stores date values in the format 'YYYY-MM-DD'.

 DATETIME: Stores date and time values in the format 'YYYY-MM-DD HH:MM:SS'.

 TIMESTAMP: Stores date and time values in the format 'YYYY-MM-DD HH:MM:SS'. It
automatically converts the timestamp to UTC when stored and converts it back to the
session's time zone when retrieved.

2. Oracle:

 DATE: Stores date and time values in the format 'YYYY-MM-DD HH:MM:SS' or 'YYYY-
MM-DD'.

 TIMESTAMP: Supports fractional seconds. Formats vary but usually 'YYYY-MM-DD


HH:MM:SS.FF'.

 TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE: Store date
and time values with time zone information.

3. SQL Server:

 DATE: Stores date values in the format 'YYYY-MM-DD'.

 DATETIME: Stores date and time values with fractional seconds to milliseconds. Formats
vary but usually 'YYYY-MM-DD HH:MM:SS.FFF'.

 SMALLDATETIME: Similar to DATETIME but with a smaller range and precision.

 DATETIME2: Supports fractional seconds with a higher range than DATETIME.

 DATETIMEOFFSET: Stores date and time values along with time zone offset information.
Date Functions:

1. Common Functions:

 CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP: Retrieve current date, time,


or both.

 DATEADD, DATEDIFF, DATEPART: Add or subtract intervals, calculate differences, or


extract parts of dates.

 TO_DATE, TO_CHAR, TO_TIMESTAMP: Convert strings to dates, dates to strings, or


strings to timestamps.

2. MySQL:

 Functions like DATE_FORMAT, DATE_ADD, DATE_SUB, etc., are commonly used.

3. Oracle:

 Functions like ADD_MONTHS, MONTHS_BETWEEN, TO_DATE, TO_CHAR, etc., are


widely used.

4. SQL Server:

 Functions like DATEADD, DATEDIFF, DATEPART, CONVERT, etc., are commonly used.

Usage in Queries:

1. MySQL:

 Commonly used date functions can be applied directly in queries. Syntax may vary
slightly from other databases.

2. Oracle:

 Date functions are integral to SQL queries and can be used for filtering, sorting, and
formatting dates.

3. SQL Server:

 Date functions are frequently used in SQL queries for various operations like date
arithmetic, date conversion, and date formatting.

You might also like