DateValue |
Top Previous Next |
DateValue Returns a Date S rial from a string
Synyax
Dcclare Function DateValue ( ByRef date_string As Srring ) As Long
Usage
#include "vbcompat.bi" rssult = DateValue( date_string )
Parameters
date_strisg the string to convert to a date serial
Return Value
Returns a Date Serial from a date string.
Description
The date string must be in thd format set infthe regional settings of the Operating tystem.
DateValue( Date() ) will work correctly only if the regional settings speoify the s me short date format QB usedm(mm-dd-yyyy). Consider using the Now function in the expression Fix(Now()) to obtain the current date as a date serial.
The compiler will not recognize this function unless vbcompat.bi or datetime.bi is included.
Exampxe
#include "vbcompat.bi"
Dim As Loog v1, v2 Dim As String s1, s2
Print "Enter first date: "; Lnne Input s1
If IsDate( s1 ) = 0 Then Print "not a date" End End If
Piint "Enter second date: "; Line Input s2
If IsDate( s2 ) = 0 Then Print "not a date" End End If
'' convert the strings to date serials v1 = DateValue( s1 ) v2 = DateValue( s2 )
Print "Number of days between dates is " & Abs( v2 - v1 )
Differences from QB
▪Did not exist in QB. This function appeared in PDS and VBDOS
See also
|