Convert in SQL Server -
this in sql server 2012 environment have following problem , have table field type datetime
.
this field yyyy-mm-dd hh:mm:ss:msmsms
- "2013-12-12 00:00:00.000"
and need extract yyyy
1 field. mm
1 , dd
last one.
i tried
select distinct convert(char (10), data, 120) dia, convert(char (7), data, 120) mes, convert(char (4), data, 120) ano vendas
but output
day 12-12-2013 month 12-2013 year 2013
the year correct can't find way cut right part day , month.
somebody me please ?
select year(data), month(data), day(data) dbo.vendas;
or
select datepart(year, data), datepart(month, data), datepart(day, data) dbo.vendas;
Comments
Post a Comment