|
|
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
Did you like this post?
|
|
|
||
|
|
|
|
|
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |






comments
0 Responses to "Create Date in T-SQL - SQL Server"Post a Comment