I have a date, suppose today date
declare @d datetime
set @d = '20101014'
I need
select @d - <six month>
where is the real number of days that contains last six month, beginning from @d.
I have a date, suppose today date
declare @d datetime
set @d = '20101014'
I need
select @d - <six month>
where is the real number of days that contains last six month, beginning from @d.
You can use
DATEADD
:EDIT: if you need the number of days up to 6 months ago you can use
DATEDIFF
:Also check this up (developing this theme):
i need to choose the algorythm depending on the condition - if there are as many days between two dates as in 6 month (ago from the last date).
I did it in this way: