In this article I will show you how you can get the
year,month and date from the given date in SQL by query.
Some of my previous queries are as follows: SQL
Query To Drop or Delete All Table, View, Stored Procedure and Trigger, Date
Time Formatting in C#.Insert,
Update, Delete, Select, Drop and Create Table In Ms Sql Server Database Table.
So here is the query to get the year, month and day. In this we user date part in build function to get the year, month and day from the given date. Here are some the date part which is used for getting the different parameters.
So here is the query to get the year, month and day. In this we user date part in build function to get the year, month and day from the given date. Here are some the date part which is used for getting the different parameters.
Parameter
|
Key
|
Year
|
yy, yyyy
|
Month
|
mm, m
|
Day
|
dd, d
|
YEAR:
SELECT DATEPART(yyyy,GETDATE()) AS FilterYear
|
MONTH:
SELECT DATEPART(MM,GETDATE()) AS FilterMonth
|
DAY:
SELECT DATEPART(DD,GETDATE()) AS FilterDay
|
0 comments:
Please let me know your view