ygCB4‖

iNyJG‖DateValue Function

CDPDz‖Returns a Date object from a string representing a date.

Svwc6‖The returned object is represented internally as a single numeric value corresponding to the specified date. This value can be used to calculate the number of days between two dates.

FVEx2‖Syntax:


  DCJAK‖DateValue(date As String)

WADQ4‖Parameters:

rK8mE‖date: A string that contains the date that will be converted to a Date object.

note

2CiE4‖The string passed to DateValue must be expressed in one of the date formats defined by your locale setting (see - Languages and Locales - General) or using the ISO date format "yyyy-mm-dd" (year, month and day separated by hyphens).


bBBqF‖Return type:

Date.

SEjHR‖Error codes:

5 Invalid procedure call

EFSA4‖Example:


  Sub ExampleDateValue
      Dim aDate As Date
      aDate = DateValue("2021-12-20")
  9mr4C‖    ' Prints the localized date
      MsgBox aDate
  aREvT‖    ' Extracts the year, month and day from the date object
      MsgBox Year(aDate)
      MsgBox Month(aDate)
      MsgBox Day(aDate)
  tBiqP‖    ' Prints the numeric value corresponding to the date (as Long type)
      MsgBox CLng(aDate)
  End Sub