RE: Error Message when using Date Functions

  • Hi,

    Could anybody please help me fix the error message? DtTemp is a smalldatetime variable.

    case

    when (( Datepart(month,dtTemp) > 8 ) or ((Datepart(month,dtTemp) = 8)

    and (DATEPART(WEEK,DAY(dtTemp))))) then

    'Sep-' + cast(right(datepart(yy,dtTemp),2) as varchar(30)) + ' to ' + 'Aug-' + right(datepart(yy,dtTemp)+1,2)

    else

    'Sep-' + cast(right(datepart(yy,dtTemp)-1,2) as varchar(30)) + ' to ' + 'Aug-' + right(datepart(yy,dtTemp),2)

    end

    I am getting the error message "An expression of non-boolean type specified in a context where a condition is expected, near ')' "

    Thank you.

  • case

    when (( Datepart(month,dtTemp) > 8 ) or ((Datepart(month,dtTemp) = 8)

    and (DATEPART(WEEK,DAY(dtTemp))) = 1 )) then

    'Sep-' + cast(right(datepart(yy,dtTemp),2) as varchar(30)) + ' to ' + 'Aug-' + right(datepart(yy,dtTemp)+1,2)

    else

    'Sep-' + cast(right(datepart(yy,dtTemp)-1,2) as varchar(30)) + ' to ' + 'Aug-' + right(datepart(yy,dtTemp),2)

    end

    you need to have something like what ive put in bold

  • Thanks a lot! It fixed the error.

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

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