Date column conversion - yyyy-mm-dd to yyyy-mm-01...please help


  • Hi,
       I have a date column values like 2013-08-25,2013-08-01,2013-09-01 and 2013-09-005

    Now I want to make them in such a way that if the datapart value is more than 1, then it should be 1...
    so, the output would be

    2013-08-01,2013-08-01,2013-09-01 and 2013-09-01..(i.e..basically all date should be 1)

    can you pls tell me the case statment for doing this, I want to use that condition in inner join to join with Date table.

    Wednesday, September 04, 2013 6:01 PM


  • SELECT DATEADD(d, 1-DAY(MyDateColumn), MyDateColumn) FROM MyTable

    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu

    • Marked as answer by Manesar Wednesday, September 04, 2013 6:28 PM
    Wednesday, September 04, 2013 6:03 PM

All replies