1

null 許容日付の違いを見つけようとしています。DateDiff(DateInterval.Day, firstDate, secondDate)では機能しますがDate、では機能しませんNullable(Of Date)。私の日付はどちらもnull可能なフィールドです。

これはエラーメッセージです:

DateDiff縮小変換なしではアクセス可能なものを呼び出すことができないため、オーバーロードの解決に失敗しました:

  • Public Function DateDiff(Interval As String, Date1 As Object, Date2 As Object, [DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek = FirstDayOfWeek.Sunday], [WeekOfYear As Microsoft.VisualBasic.FirstWeekOfYear = FirstWeekOfYear.Jan1]) As Long: 引数一致パラメータが からにInterval絞り込まれます。Microsoft.VisualBasic.DateIntervalString

  • Public Function DateDiff(Interval As Microsoft.VisualBasic.DateInterval, Date1 As Date, Date2 As Date, [DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek = FirstDayOfWeek.Sunday], [WeekOfYear As Microsoft.VisualBasic.FirstWeekOfYear = FirstWeekOfYear.Jan1]) As Long: 引数一致パラメータが からにDate1絞り込まれます。Date?Date

  • Public Function DateDiff(Interval As Microsoft.VisualBasic.DateInterval, Date1 As Date, Date2 As Date, [DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek = FirstDayOfWeek.Sunday], [WeekOfYear As Microsoft.VisualBasic.FirstWeekOfYear = FirstWeekOfYear.Jan1]) As Long: 引数一致パラメータが からにDate2絞り込まれます。Date?Date

4

3 に答える 3

2

.ValuenullableDateオブジェクトでを呼び出す必要があります。

DateDiff(DateInterval.Day, firstDate.Value, secondDate.Value) 
于 2013-08-15T15:55:28.667 に答える
-1

2 Years Late to Answer the question.... :)

The error Above could be caused by a data type miss match. Use DateValue function e.g

DateDiff(DateInterval.Day, DateValue(stringwiDate.text), DateValue(string2witDate.text))
于 2015-11-28T14:10:57.600 に答える