-1

I am using SQL Server 2012 and I have a column called Created in one of my tables.

The Created column has dates in the datetime format: 2014-02-08 14:01:20.347

I need to convert the dates into the following format. For example, if date is 2014-02-08 14:01:20.347, then I need it to become 2014-02-01 00:00:00.000

How can I achieve this?

user3115933
  • 4,303
  • 15
  • 54
  • 94

2 Answers2

2

I would use datefromparts():

select datefromparts(year(created), month(created), 1)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
1
SELECT DATEADD(month, DATEDIFF(month, 0, date_column), 0) 
akshay
  • 777
  • 4
  • 15