DateTime Data Type

Holds 64-bit (8-byte) date and time values in the range 1 January 0001 00:00:00–31 December 9999 23:59:59.


Default value
When you declare a variable of type DateTime and do not give it an initial value, the value is 0000/00/00 00:00:00, which is not a correct date, but not an error.
Type characters
DateTime has no type character.

DateTime literal

Date literal

year / month / day

Time literal

hours : minutes [ : seconds ]

Date/time construct

year / month / day hours : minutes [ : seconds ]

The above named parts of a date or time must be decimal digits. Some more rules follow.

Divides the parts of a date. The alternative is hyphens (-).
Optional number of seconds. You can specify a fraction of a second if you put a decimal point (.) between two sets of digits. The fractional part can have a maximum of seven digits. Digits after that are ignored.

Shared methods and properties

DateTime.Day As Int32
Returns the current day of the month.
DateTime.Default As DateTime
Returns the default value, 0000/00/00 00:00:00.
DateTime.Hour As Int32
Returns the current hour.
DateTime.Local As DateTime
Returns the local date and time of the system.
DateTime.Millisecond As Int32
Returns the current millisecond.
DateTime.Minute As Int32
Returns the current minute.
DateTime.Month As Int32
Returns the current month.
DateTime.Parse(str As String, Optional #format As Format) As DateTime
Tries to parse a string that shows as a date or time.
If #format is not given or is #Null, it uses the format of the local culture. Or you can make it clear with Format.UserLocale.
DateTime.Second As Int32
Returns the current second.
DateTime.Size As Int32
Returns the number of available bytes. This is always 8.
DateTime.UTCLocal As DateTime
Returns the current date and time in UTC.
DateTime.Year As Int32
Returns the current year.

Type conversions

ViviFire can change between the type DateTime and other types. Some conversions can be in one direction only.

Conversion to DateTime

From type Result
Integer types If you add the integer 1 to a DateTime, the value increases 100 nanoseconds (0:0:0.0000001). Other values are a multiple of this.

Conversion from DateTime

To type Result
String The short date format specified by the user's locale and the time as a 12- or 24-hour format. If you try to convert the default value to String, the result is TBD.

Symmetrical conversions

Type Result
floating-point types A value of 0.0 changes to 1899/12/30. Other whole numbers are the number of days from this. A value with a fractional part is that fraction of a day. For example, .5 is 12:00:00.


Dim date As DateTime = 2013/12/11
Dim time As DateTime = 10:09:08
Dim combo = 2013-12-11 10:09:08.07

See also