SQL

Get Largest date

CREATE FUNCTION fn_greatest_date (@date_1 datetime, @date_2 datetime, @date_3 datetime) RETURNS datetime AS BEGIN DECLARE @return_date datetime SELECT @return_date = MAX(dateval) FROM ( SELECT @date_1 AS dateval UNION ALL SELECT @date_2 UNION ALL SELECT @date_3 ) datesCREATE FUNCTION fn_greatest_date (@date_1 datetime,…Continue Reading →