SQL DATEPART() Function
The DATEPART() function is used to return a single part of a date/time, such as year, month, day, hour, minute, etc.
Syntax
DATEPART(datepart,date)
Example:-
SELECT DATEPART(yyyy,OrderDate) AS OrderYear,
DATEPART(mm,OrderDate) AS OrderMonth,
DATEPART(dd,OrderDate) AS OrderDay,
FROM Orders
WHERE OrderId=1
The DATEPART() function is used to return a single part of a date/time, such as year, month, day, hour, minute, etc.
Syntax
DATEPART(datepart,date)
Example:-
SELECT DATEPART(yyyy,OrderDate) AS OrderYear,
DATEPART(mm,OrderDate) AS OrderMonth,
DATEPART(dd,OrderDate) AS OrderDay,
FROM Orders
WHERE OrderId=1
No comments:
Post a Comment