none
Need help in Date Query

    Question

  • HI Guys

    I have date like 2008-10-31 16:36:567 I want to convert like 20081031 00:00:000 for this

    I'm using convert(datetime,(convert(varchar(8),replace('2008-10-31 16:36:567','-',''))))

    is there any option to do this?

    Tuesday, August 31, 2010 2:16 AM

Answers

  • DECLARE @vDate DATETIME
    SET @vDate = '2008-10-31 16:36:00.000'
    SELECT Convert(VARCHAR(20),@vDate,112) + ' 00:00:000'
    SELECT CAST(YEAR(@vDate) AS VARCHAR(10)) + CAST(MONTH(@vDate) AS VARCHAR(10)) + CAST(DAY(@vDate) AS VARCHAR(10)) + ' 00:00:00.000'
    
    

    My Blog
    Tuesday, August 31, 2010 3:42 AM

All replies