I have the following two columns:
date (datetime),
month_after_release (int)
These columns are filled monthly as part of an incremental update
.
Let's say there was a release on Jan 1, 2015. This means we are currently in the 9th month after release [formula: round off((current date - release date)/30,0)+1 = 9]
. So if I am now importing data with a current date (Sep 21, 2015), the two columns should be filled like this:
date = 2015-09-21 00:00:00.000
month_after_release = 9
In October, data which gets imported should then get the following information:
date = 2015-10-21 00:00:00.000
month_after_release = 10
How can I achieve this? One possibility which came to my mind would be to have a separate mapping table, which maps every single date to "month_after_release", but I was wondering if there is a better possibility?
The information when a release was is stored in a separate table, which looks like this:
ReleaseID,
Release_start_date
select releaseDate, DateDiff(MM, releaseDate, getdate()) MonthsSinceRelease
from table t
That's how you calculate it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments