Te paso mas ejemplos
COMPARAR FECHAS
[code]Sub compareDate (d as date)
Dim currentDate as Date
Dim futureDate as Date
currentDate = new Date
futureDate = new Date(currentDate.Year, currentDate.Month, currentDate.day + 5)
if d < currentDate then
’ Code here
elseif d = currentDate then
’ Code here
elseif d < futureDate then
’ Code here
else
’ Code here
end if
End Sub
[/code]
Calcular Diferencia de dias entre dos fechas
[code] dim diff as double
dim d1 as new date
dim d2 as new date
d1.SQLDate = “5999-12-31”
d2.SQLDate = “1950-12-31”
diff = d1.TotalSeconds - d2.TotalSeconds
diff = diff / 3600.0 / 24.0
MsgBox format( diff, “0” ) + " days"[/code]
vERIFICAR FECHA VALIDA
[code]DIm mybool as boolean
DIM mydate as date
DIM Formatdate as string
mybool= parsedate(GMT FORMAT,mydate)
Formatdate = mydate.short date
[/code]
REGISTRAR FECHA EN UN CAMPO RS
dim d as date
if parseDate(txtLastMod.text, d) = true then
//if date is good, save it to recordset
rs.Field("lastdate").DateValue = d
end
Comparar Fechas
[code]Dim Today,XDay As New Date
Dim d1,d2 As Double
Dim Yr,Mo,Dy As Integer
d1=Today.TotalSeconds // Real-time value
XDay.Year=Yr
XDay.Month=Mo
XDay.Day=Dy
d2=XDay.TotalSeconds // Stored value
If d1>d2 Then
Alarm.Play
End if
[/code]
Comparar Fechas EJEMPLO 2
[code]Dim d1 as new date
Dim d2 as new date
Dim dateToCheck as new date
d1.TotalSeconds = self.mCurrentDate.TotalSeconds
d2.TotalSeconds = self.mCurrentDate.TotalSeconds
d2.Year = dateToCheck.Year
d2.Month = dateToCheck.Month
d2.day = dateToCheck.day
msgbox str("Greater than: " + str(d1>d2))
msgbox str("Equals: " + str(d1=d2))
msgbox str("Less than: " + str(d1<d2))[/code]
Comparar Fechas
[code]Dim dateToCheck as new date
Dim d1 as new date(self.mCurrentDate.Year, self.mCurrentDate.Month, self.mCurrentDate.day )
Dim d2 as new date(dateToCheck.Year, dateToCheck.Month, dateToCheck.day )
msgbox str("Greater than: " + str(d1>d2))
msgbox str("Equals: " + str(d1=d2))
msgbox str("Less than: " + str(d1<d2))
[/code]