Here’s a very simple query that shows how to create a Date using T-SQL if you are given the Day, Month and Year
OUTPUT
If you are given only the Day and Month, then here’s a nice query written by Peter Larsson:
DECLARE
@Day smallint = 24,
@Month smallint = 4
SELECT DATEADD(MONTH, 12 * YEAR(GETDATE())
+ @Month - 22801, @Day - 1)
As [Date]
OUTPUT
No comments:
Post a Comment