Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current Month and year in sql server 2008 r2 [closed]

I am currently new in C# & SQL.

How do I get the current month and year in SQL Server 2008 R2?

like image 768
Puseletso Michelle Avatar asked Apr 23 '13 14:04

Puseletso Michelle


1 Answers

SQL Server

SELECT GETDATE() AS CurrentDateTime
     , YEAR(GETDATE()) AS CurrentYear
     , MONTH(GETDATE()) AS CurrentMonth

C#

var now = DateTime.Now;
var currentYear = now.Year;
var currentMonth = now.Month;
like image 77
Cyril Gandon Avatar answered Oct 09 '22 21:10

Cyril Gandon