Skip to main content

DateValue()

Syntax: DateValue(StringDate as String) as Date

The DateValue function assignes a specific data to a type Date variable.  Converting a string representation of a date into a Date value.

Parameters: The StringDate can be different date formats in string, the following are a few examples:

  • "January 10 2007"
  • "January 10" - defaults to current system year
  • "Jan 10 2007"
  • "10/Jan/2007"
  • "10/01/2007"
  • "10/Jan/2007 14:10:10" - won't return the time portion
Script
Sub Main
	Dim strDate As Date
	strDate = DateValue("January 10 2007") 	'10/01/2007 
	MsgBox strDate	 
	strDate = DateValue("January 10") 	'10/01/ 	Current System Year
	MsgBox strDate
	strDate = DateValue("Jan 10 2007") 	'10/01/2007
	MsgBox strDate 	 
	strDate = DateValue("10/Jan/2007") 	'10/01/2007 
	MsgBox strDate	 
	strDate = DateValue("10/01/2007") '	10/01/2007 
	MsgBox strDate	 
	strDate = DateValue("10/Jan/2007 14:10:10") 	'10/01/2007 	Time will Not be returned
	MsgBox strDate
	strDate = DateValue("January 10 2007")
	MsgBox strDate
End Sub

 

IDEAScript Language