Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ozandalkiran
Starting Member
13 Posts |
Posted - 2013-01-10 : 03:35:56
|
SaleBegin2007-10-30 16:57:54.000how can i get only year and mounth?please help me. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-10 : 03:39:06
|
YEAR(datefield),MONTH(datefield) if you want them in separate columnif you want them combined useDATENAME(yy,date) + RIGHT('00' + CAST(MONTH(datefield) AS varchar(2)),2)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-01-10 : 04:16:51
|
In MSSQL 2012, You can use FORMAT() function to get YYYYMMSELECT FORMAT(GETDATE(), 'yyyyMM') AS [YYYYMM]--Chandu |
|
|
ozandalkiran
Starting Member
13 Posts |
Posted - 2013-01-10 : 04:38:26
|
thank youquote: Originally posted by visakh16 YEAR(datefield),MONTH(datefield) if you want them in separate columnif you want them combined useDATENAME(yy,date) + RIGHT('00' + CAST(MONTH(datefield) AS varchar(2)),2)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-10 : 04:46:14
|
wlcm------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|