Collections:
Performing Comparison on Date and Time Values in SQL Server
How To Perform Comparison on Date and Time Values in SQL Server Transact-SQL?
✍: FYIcenter.com
Comparison operations on date and time values can be performed in the same way as numeric values. The comparison rule is simple: a date and time value in the future has a greater value than a date and time value in the past. The tutorial exercise below shows you a good example:
-- Future date has a greater value
DECLARE @his_birth_date DATETIME, @her_birth_date DATETIME;
SET @his_birth_date = '1987-05-19';
SET @her_birth_date = '1988-07-07';
SELECT CASE WHEN @his_birth_date < @her_birth_date THEN
'He is older.'
ELSE
'She is older.'
END;
GO
He is older.
⇒ Performing Comparison on Character Strings in SQL Server
⇐ Performing Comparison on Floating Point Numbers in SQL Server
⇑ Boolean Values and Logical Operations in SQL Server Transact-SQL
2017-01-21, 2521🔥, 0💬
Popular Posts:
What Are Date and Time Functions in MySQL? MySQL offers a number of functions for date and time valu...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
What Happens If the UPDATE Subquery Returns Multiple Rows in SQL Server? If a subquery is used in a ...
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want t...