Q1
True / FalseThe GETDATE() function returns the current system date and time.
The GETDATE() function retrieves the current system date and time from the server.
Q2
True / FalseThe DATEADD function can add a specified time interval to a date.
The DATEADD function is used to add or subtract a specified time interval from a date.
Q3
True / FalseThe DATEDIFF function returns the number of specified datepart boundaries crossed between two dates.
The DATEDIFF function calculates the difference between two dates in terms of the specified date part, such as year, month, day, etc.
Q4
True / FalseThe GETDATE() function can be used to find the difference between two dates.
The GETDATE() function retrieves the current system date and time, but it does not perform date calculations.
Q5
True / FalseThe SYSDATETIME() function returns the current system date and time with more precision than GETDATE().
The SYSDATETIME() function returns the current system date and time, similar to GETDATE(), but with more precision.
Q6
True / FalseThe DATEPART function can be used to extract parts of a date, such as the year or month.
The DATEPART function extracts the specified part (such as year, month, day, etc.) from a given date.
Q7
True / FalseThe EOMONTH function returns the first day of the month.
The EOMONTH function returns the last day of the month for a given date, not the first day.
Q8
True / FalseThe DATEFROMPARTS function creates a date from individual year, month, and day values.
The DATEFROMPARTS function constructs a date from the provided year, month, and day values.
Q9
True / FalseThe GETUTCDATE() function returns the current date and time in UTC.
The GETUTCDATE() function retrieves the current date and time in Coordinated Universal Time (UTC).
Q10
True / FalseThe DATENAME function returns the name of the specified datepart of a date.
The DATENAME function returns the name of the specified datepart (such as 'Monday' for day, 'January' for month) from a date.
Q11
True / FalseThe DATEADD function can subtract days from a given date.
SQL Code
SELECT DATEADD(day, -10, '2024-08-01');
SELECT DATEADD(day, -30, '2024-08-01');
SELECT DATEADD(day, -7, '2024-08-01');
SELECT DATEADD(day, -365, '2024-08-01');
SELECT DATEADD(day, -1, '2024-08-01');
The DATEADD function can add or subtract a specified time interval from a given date. By using a negative value, you can subtract days from the date.
Q12
True / FalseThe DATEDIFF function can return the number of weeks between two dates.
SQL Code
SELECT DATEDIFF(week, '2024-01-01', '2024-08-01');
SELECT DATEDIFF(week, '2023-01-01', '2024-08-01');
SELECT DATEDIFF(week, '2024-07-01', '2024-08-01');
SELECT DATEDIFF(week, '2024-06-01', '2024-08-01');
SELECT DATEDIFF(week, '2023-01-01', '2023-08-01');
The DATEDIFF function calculates the difference between two dates in terms of the specified date part. In this case, 'week' is used to find the number of weeks between the dates.
Q13
True / FalseThe FORMAT function can be used to format dates into different styles.
SQL Code
SELECT FORMAT(GETDATE(), 'yyyy-MM-dd');
SELECT FORMAT(GETDATE(), 'MMMM dd, yyyy');
SELECT FORMAT(GETDATE(), 'dd/MM/yyyy');
SELECT FORMAT(GETDATE(), 'MM-dd-yyyy');
SELECT FORMAT(GETDATE(), 'yyyyMMdd');
The FORMAT function allows formatting dates and times into various styles and formats, such as 'yyyy-MM-dd', 'MMMM dd, yyyy', etc.
Q14
True / FalseThe DATEPART function cannot be used to extract the hour part from a date.
SQL Code
SELECT DATEPART(hour, GETDATE());
SELECT DATEPART(hour, '2024-08-01 12:34:56');
SELECT DATEPART(hour, '2024-08-01 23:45:00');
SELECT DATEPART(hour, '2024-08-01 00:00:00');
SELECT DATEPART(hour, '2024-08-01 06:30:00');
The DATEPART function can extract various parts of a date, including the hour, minute, and second. Therefore, it can indeed extract the hour part from a date.
Q15
True / FalseThe DATENAME function returns the numeric value of the specified date part.
SQL Code
SELECT DATENAME(month, '2024-08-01');
SELECT DATENAME(weekday, '2024-08-01');
SELECT DATENAME(year, '2024-08-01');
SELECT DATENAME(hour, '2024-08-01 12:34:56');
SELECT DATENAME(day, '2024-08-01');
The DATENAME function returns the name of the specified date part (e.g., 'January' for month, 'Monday' for weekday), not the numeric value.
Q23
Single ChoiceWhich function creates a date from individual year, month, and day values?
SQL Code
SELECT DATEFROMPARTS(2024, 8, 1);
SELECT DATEFROMPARTS(2020, 2, 29);
SELECT DATEFROMPARTS(2023, 12, 31);
SELECT DATEFROMPARTS(2024, 1, 1);
SELECT DATEFROMPARTS(2024, 7, 15);
The DATEFROMPARTS function constructs a date from the provided year, month, and day values.
Q24
Single ChoiceWhich function adds or subtracts a specified time interval from a date?
SQL Code
SELECT DATEADD(day, 10, '2024-08-01');
SELECT DATEADD(month, 6, '2024-08-01');
SELECT DATEADD(year, -1, '2024-08-01');
SELECT DATEADD(hour, 5, GETDATE());
SELECT DATEADD(minute, -30, GETDATE());
The DATEADD function is used to add or subtract a specified time interval (such as days, months, years) from a given date.
Q26
Single ChoiceWhich function formats a date into a specified format?
SQL Code
SELECT FORMAT(GETDATE(), 'yyyy-MM-dd');
SELECT FORMAT(GETDATE(), 'MMMM dd, yyyy');
SELECT FORMAT(GETDATE(), 'dd/MM/yyyy');
SELECT FORMAT(GETDATE(), 'MM-dd-yyyy');
SELECT FORMAT(GETDATE(), 'yyyyMMdd');
The FORMAT function allows formatting dates and times into various styles and formats, such as 'yyyy-MM-dd', 'MMMM dd, yyyy', etc.
Q27
Single ChoiceWhich function returns the difference between two dates in terms of the specified date part?
SQL Code
SELECT DATEDIFF(day, '2024-01-01', '2024-08-01');
SELECT DATEDIFF(month, '2024-01-01', '2024-08-01');
SELECT DATEDIFF(year, '2020-01-01', '2024-08-01');
SELECT DATEDIFF(hour, '2024-08-01 00:00:00', '2024-08-01 12:34:56');
SELECT DATEDIFF(minute, '2024-08-01 12:00:00', '2024-08-01 12:34:56');
The DATEDIFF function calculates the difference between two dates in terms of the specified date part (such as days, months, years, etc.).
Q32
Multiple ChoiceWhich functions can be used to add or subtract time intervals from a date? Select all that apply.
SQL Code
SELECT DATEADD(day, 10, '2024-08-01');
SELECT DATEADD(month, 6, '2024-08-01');
SELECT DATEADD(year, -1, '2024-08-01');
SELECT DATEADD(hour, 5, GETDATE());
SELECT DATEADD(minute, -30, GETDATE());
The DATEADD function can be used to add or subtract various time intervals (days, months, years, hours, minutes) from a given date.
Q33
Multiple ChoiceWhich functions can be used to extract parts of a date? Select all that apply.
SQL Code
SELECT DATEPART(year, GETDATE());
SELECT DATEPART(month, GETDATE());
SELECT DATEPART(day, GETDATE());
SELECT DATEPART(hour, GETDATE());
SELECT DATEPART(minute, GETDATE());
The DATEPART function can extract various parts of a date (year, month, day, hour, minute, etc.).
Q35
Multiple ChoiceWhich functions can calculate the difference between two dates? Select all that apply.
SQL Code
SELECT DATEDIFF(day, '2024-01-01', '2024-08-01');
SELECT DATEDIFF(month, '2024-01-01', '2024-08-01');
SELECT DATEDIFF(year, '2020-01-01', '2024-08-01');
SELECT DATEDIFF(hour, '2024-08-01 00:00:00', '2024-08-01 12:34:56');
SELECT DATEDIFF(minute, '2024-08-01 12:00:00', '2024-08-01 12:34:56');
The DATEDIFF function calculates the difference between two dates in terms of the specified date part (days, months, years, hours, minutes, etc.).
Q42
Multiple ChoiceWhich functions can be used to extract parts of a date? Select all that apply.
SQL Code
SELECT DATEPART(year, GETDATE());
SELECT DATEPART(month, GETDATE());
SELECT DATEPART(day, GETDATE());
SELECT DATEPART(hour, GETDATE());
SELECT DATEPART(minute, GETDATE());
The DATEPART function can extract various parts of a date (year, month, day, hour, minute, etc.).
Q44
Multiple ChoiceWhich functions can calculate the difference between two dates? Select all that apply.
SQL Code
SELECT DATEDIFF(day, '2024-01-01', '2024-08-01');
SELECT DATEDIFF(month, '2024-01-01', '2024-08-01');
SELECT DATEDIFF(year, '2020-01-01', '2024-08-01');
SELECT DATEDIFF(hour, '2024-08-01 00:00:00', '2024-08-01 12:34:56');
SELECT DATEDIFF(minute, '2024-08-01 12:00:00', '2024-08-01 12:34:56');
The DATEDIFF function calculates the difference between two dates in terms of the specified date part (days, months, years, hours, minutes, etc.).