sql - Using ISNULL and DATEDIFF of dates to days and sum the result in select -


i couple of iterations in query. need number of days result. have 2 types of dates (ae dates) , (ipdates). each of them has start date , end date (aestartdatetime,aeenddatetime) , (ipstartdate , ipenddate)

i select there table , substract both pairs each 2 number of days result 2 values in days format, want sum them. main condition these column's can null

select ((isnull(datediff(day , aestartdatetime , aeenddatetime)),0)  + (isnull(datediff(day , ipstartdate , ipenddate)),0))  'ipbeddays' details 

this not work. can help

just parenthesis out of place:

select isnull(datediff(day, aestartdatetime, aeenddatetime),0) + isnull(datediff(day, ipstartdate, ipenddate),0) 'ipbeddays' details 

the last parenthesis in chunk below came before third argument of isnull() (same other isnull() statement well):

isnull(datediff(day, aestartdatetime, aeenddatetime)) 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -