Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

DATEDIFF

$
0
0

Hi,

I am trying to get the correct calculation for months between 2 dates. I have some logic already in Access which I know works and I am trying to get the same out put in SQL but it's not quite there and I think it could be linked to the ROUND function which Access logic has by my SQL server logic doesn't, does anyone know what I need to apply to my SQL logic to match that in Access please?

Access Logic

Months: IIf(Round((DateValue([Date_Required])-DateValue([Date_in]))/(365/12),0)=0,1,Round((DateValue([Date_Required])-DateValue([Date_in]))/(365/12),0))

SQL Server Logic

DATEDIFF(D,FINANCIALS_LIFE_TO_DATE.DATE_IN, FINANCIALS_LIFE_TO_DATE.DATE_REQUIRED) / (365/12) AS MRR_CONTRACT_LENGTH,



Viewing all articles
Browse latest Browse all 7129

Trending Articles



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