vb.net - DateDiff doesn’t work with nullables -
i’m trying find difference between nullable dates. datediff(dateinterval.day, firstdate, seconddate)
works date
, not nullable(of date)
. both dates nullable fields.
this error message:
overload resolution failed because no accessible
datediff
can called without narrowing conversion:
public function datediff(interval string, date1 object, date2 object, [dayofweek microsoft.visualbasic.firstdayofweek = firstdayofweek.sunday], [weekofyear microsoft.visualbasic.firstweekofyear = firstweekofyear.jan1]) long
: argument matching parameterinterval
narrowsmicrosoft.visualbasic.dateinterval
string
.
public function datediff(interval microsoft.visualbasic.dateinterval, date1 date, date2 date, [dayofweek microsoft.visualbasic.firstdayofweek = firstdayofweek.sunday], [weekofyear microsoft.visualbasic.firstweekofyear = firstweekofyear.jan1]) long
: argument matching parameterdate1
narrowsdate?
date
.
public function datediff(interval microsoft.visualbasic.dateinterval, date1 date, date2 date, [dayofweek microsoft.visualbasic.firstdayofweek = firstdayofweek.sunday], [weekofyear microsoft.visualbasic.firstweekofyear = firstweekofyear.jan1]) long
: argument matching parameterdate2
narrowsdate?
date
.
if know they’re not nothing
, values:
datediff(dateinterval.day, firstdate.value, seconddate.value)
but can take advantage of operator overloading, since isn’t vb6:
(seconddate.value - firstdate.value).days
Comments
Post a Comment