{{fbdoc item="title" value="DATEVALUE"}}----
Returns a [[ProPgDates|Date Serial]] from a string

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **""DateValue""** ( [[KeyPgByref|byref]] //date_string// [[KeyPgAs|as]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgDouble|double]]
##
{{fbdoc item="usage"}}##
	#include "vbcompat.bi"
	//result// = **""DateValue""**( //date_string// )
##
{{fbdoc item="param"}}
	##//date_string//##
		the string to convert to a date serial

{{fbdoc item="ret"}}
	Returns a [[ProPgDates|Date Serial]] from a date string.

{{fbdoc item="desc"}}
	The date string must be in the format set in the regional settings of the Operating System. 
	
	##**""DateValue""**( Date() )## will work correctly only if the regional settings specify the same short date format QB used (##mm-dd-yyyy##).  Consider using the ##[[KeyPgNow|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.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/dates/datevalue.bas"}}%%(freebasic)
#include "vbcompat.bi"

dim as integer v1, v2
dim as string  s1, s2

print "Enter first date: ";
line input s1

if IsDate( s1 ) = 0 then
  print "not a date"
  end
end if

print "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 )
%%

{{fbdoc item="diff"}}
	- Did not exist in QB. This function appeared in PDS and VBDOS

{{fbdoc item="see"}}
	- [[ProPgDates|Date Serials]]
	- ##[[KeyPgDateSerial|DateSerial]]##
	- ##[[KeyPgTimeValue|TimeValue]]##

{{fbdoc item="back" value="CatPgDate|Date and Time Functions"}}