Skip to content
Advertisement

Problems finding out Active users due to Hire/Resign Date

In my Employee table in SQL Server I have two datetime columns: HiringDate and ResignDate. I want to create a new column Status (Active, Inactive) in a view.

  • If HiringDate is NULL or greater than today = Inactive
  • If HiringDate is Active but ResignDate is earlier than today then Status also have to be Inactive.

Do I have to make some kind of nested case to make this work and I’m also wondering do I have to convert it to date format so the time portion are not included.

Would be very thankful for help.

Here is what ive tried so far but it doesnt work properly…

Advertisement

Answer

Try this below combine logic in one CASE expression:

Can you please try with this below new logic-

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement