0

Hi All, please help me how to convert dd/mm/yyyy to mm/yyyy in MS SQL server

i have column in the table having values 1/11/2019,2/11/2019,3/11/2019....i need another column like 11/2019,11/2019,11/2019... month wise...how to convert dd/mm/yyyy to mm/yyyy in MS SQL server.... thanks in advance

6th Nov 2019, 9:57 AM
vijay
vijay - avatar
1 Resposta
+ 3
declare @dt datetime = GETDATE() SELECT LEFT('0' + CAST(MONTH(@dt) as varchar(2)),2) + '-' + CAST(YEAR(@dt) as char(4))
6th Nov 2019, 11:02 AM
r8w9
r8w9 - avatar