Date field case statement

  • Hello,

    I'm trying to write a case statement for a datetime field to use the logdate as the datestamp when the time in logdate is equal to '00:00:00.000'

    Datestamp= case when LogDate like '% 00:00:00.000' then LogDate else DATEADD(day,-1,Datestamp) end

    The table looks like

    Datestamp Logdate

    2015-09-30 00:00:00.0002015-10-01 00:00:00.000

    But I would like it to populate as

    Datestamp Logdate

    2015-10-01 00:00:00.0002015-10-01 00:00:00.000

    Thanks!

  • Try

    Case when LogDate = cast(LogDate as date) ...


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply