We help IT Professionals succeed at work.

# calculate date

on
178 Views
I am working on a case statement, but I am unsure I am getting the logic from correct from the pseudo code. I was wondering if someone can give me a hand and let me know if my case seems to be doing what expected based on the words.

That is:

ContractOpenStartDate = Equal to TODAY if in the middle of contract OR if contract has not started yet OR NULL if Contract is closed

``````CASE
WHEN [sbo_wcnd].[ContractStart] <= @Today AND [sbo_wcnd].[ContractEnd] >= @Today
THEN @Today
WHEN [sbo_wcnd].[ContractStart] > @Today
THEN [sbo_wcnd].[ContractStart]
WHEN [sbo_wcnd].[ContractEnd] < @Today
THEN NULL
END	AS ContractOpenStartDate
``````

And also...
ContractOpenEndDate = ALWAYS EndDate or NULL if contract is closed.
``````CASE
WHEN [sbo_wcnd].[ContractStart] <= @Today AND [sbo_wcnd].[ContractEnd] >= @Today
THEN @Today
WHEN [sbo_wcnd].[ContractStart] > @Today
THEN [sbo_wcnd].[ContractStart]
WHEN [sbo_wcnd].[ContractEnd] < @Today
THEN NULL
END	AS ContractOpenStartDate
``````
A contract is closed if its end date is in the past.

Thank you very much for your help.
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2014
Awarded 2013
Commented:
This problem has been solved!
###### Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

Deciding to stick with EE.

Mohamed Asif

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant