The following sql
queries can give year part in a date in YYYY format:
SELECT DATEPART(YEAR, GETDATE()) AS [year]
SELECT DATEPART(YYYY, GETDATE()) AS [year]
SELECT DATEPART(YY, GETDATE()) AS [year]
| year |
| 2014 |
| 2014 |
The following sql
queries can give year part in a date in YY format:
SELECT RIGHT(DATEPART(YEAR, GETDATE()), 2) AS [year]
SELECT RIGHT(DATEPART(YYYY, GETDATE()), 2) AS [year]
SELECT RIGHT(DATEPART(YY, GETDATE()), 2) AS [year]
| year |
| 14 |
The following query
gives day of year:
SELECT DATEPART(Y, GETDATE())AS [day
of year]
| day of year|
| 190 |(09th July 2014)
| 190 |(09th July 2014)