Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

how do i calculate the dates in this scenario

$
0
0
I have a situation here and i am not able to think through it

there are 4 date columns in a table and i need to do something like below

First Record start date is the start date, and end date is the next start date -1
Next start date is next start date, and end date is the first end date of the record set of the end dates
Next start date pervious end date + 1 and end date is the current end date
Next start date is the current date and next end date is the current end date

for example lets say we have a table like below

CustomerID CustomerType CustomerEffDt   CustomerTrmDt CustNationalBgnDt CustNationalEndDt
1                  National           2013-08-05        9999-12-31       2010-11-08            2011-11-02


Now my question is, we would have to calculate the customer effective start and begin dates and national begin and end dates based on the above criteria
we would have to create 4 rows based on the above scenario

I am going mad and not able to think through this
Can somebody help me

Thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>