Question : Datediff HALF YEAR?? and dateadd

Hi Guys

i have this query

DateAdd(q,DATEDIFF(q,t2.StartDate,getdate()),t2.StartDate) NextInvoiceQuarter,

this gives me the nextquarter invoice date.
Now my problem is that sum customers needs to be charged every half year. How do i calculate that? it doesnt seem like datediff has a half year function?

Answer : Datediff HALF YEAR?? and dateadd

Try the following:

Of course you may need to pull the value 2 or 6 from another column in your query.

You could have a column called CustomerChargedEveryNQuarters which has values 1 or 2
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
DateAdd(q, 2 * DATEDIFF(q, t2.StartDate,getdate()),t2.StartDate) NextInvoiceQuarter
 
or
 
DateAdd(m, 6 * DATEDIFF(m, t2.StartDate,getdate()), t2.StartDate) NextInvoiceQuarter
 
or even
 
DateAdd(q, CustomerChargedEveryNQuarters  * DATEDIFF(q, t2.StartDate,getdate()), t2.StartDate) NextInvoiceQuarter
Random Solutions  
 
programming4us programming4us