Imports System.Runtime.CompilerServices Namespace Extensiones Public Module DateOnlyExtensions Public Function Minimo(Fecha1 As Nullable(Of DateOnly), Fecha2 As Nullable(Of DateOnly)) As Nullable(Of DateOnly) Dim t1, t2 As DateOnly If Fecha1.HasValue Then t1 = Fecha1.Value If Fecha2.HasValue Then t2 = Fecha2.Value If t1 < t2 Then Return Fecha1 Else Return Fecha2 End If End Function Public Function Maximo(Fecha1 As Nullable(Of DateOnly), Fecha2 As Nullable(Of DateOnly)) As Nullable(Of DateOnly) Dim t1, t2 As DateOnly If Fecha1.HasValue Then t1 = Fecha1.Value If Fecha2.HasValue Then t2 = Fecha2.Value If t1 > t2 Then Return Fecha1 Else Return Fecha2 End If End Function Public Function ValorNumerico(Fecha As Nullable(Of DateOnly)) As Long If Fecha Is Nothing Then Return 0 Else Return Fecha.Value.Year * 10000 + Fecha.Value.Month * 100 + Fecha.Value.Day End If End Function Public Function ToDateTime(Fecha As Nullable(Of DateOnly)) As DateTime If Fecha Is Nothing Then Return Nothing Else Return New DateTime(Fecha.Value.Year, Fecha.Value.Month, Fecha.Value.Day) End If End Function Public Function ToDateTime(Fecha As DateOnly) As DateTime Return New DateTime(Fecha.Year, Fecha.Month, Fecha.Day) End Function Public Function ToDate(Fecha As Nullable(Of DateOnly)) As DateTime If Fecha Is Nothing Then Return Nothing Else Return New Date(Fecha.Value.Year, Fecha.Value.Month, Fecha.Value.Day) End If End Function Public Function ToDate(Fecha As DateOnly) As DateTime Return New Date(Fecha.Year, Fecha.Month, Fecha.Day) End Function End Module End Namespace