Need help with the query

  • Can anyone help me as I am getting error on this query.

    Msg 156, Level 15, State 1, Line 21

    Incorrect syntax near the keyword 'between'.

    declare @EoM datetime

    declare @BoD datetime

    select @EoM = dbo.fn_Get_EOM

    select @Bod =GETDATE()

    select top 10 empID,FromDate,ToDate

    from employees

    where status = 'employed'

    and CASE WHEN @EoM between FromDate and ToDate THEN @EOM

    ELSE @BoD between FromDate and ToDate

    Please help me and Thanks in advance

  • ELSE @BoD END between

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • ELSE @BoD END between FromDate and ToDate

  • Thank you so much and I really appreciate your reply.It worked perfect.Thanks a lot once again for each one of you.

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

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