Xojo.Core.Date.FromText

From Xojo Documentation

Shared Method

Xojo.Core.Date.FromText(input As Text, loc As Xojo.Core.Locale = Nil) As Xojo.Core.Date

Converts a textual date to an actual date using the optional locale.

Notes

The resulting date is in the current time zone (Xojo.Core.TimeZone.Current).

When no locale is specified, the input text can be in either SQLDate (YYYY-MM-DD) or SQLDateTime (YYYY-MM-DD HH:MM:SS) formats.

If you specify a locale, the input text must be formatted to match the locale you specify.

Use format patterns from: Unicode Date Format Patterns.

If you supply input text that cannot be formatted, then a RuntimeException is raised with a Parse Error.

Sample Code

Convert text values to a date:

Dim SQLDateTime As Text = "2015-08-01 11:00"
Dim myDate1 As Xojo.Core.Date = Xojo.Core.Date.FromText(SQLDateTime)

Dim SQLDate As Text = "2018-06-01"
Dim myDate2 As Xojo.Core.Date = Xojo.Core.Date.FromText(SQLDate)

Dim dateValue As Text = Xojo.Core.Date.Now.ToText(Xojo.Core.Locale.Current)
Dim myDate3 As Xojo.Core.Date = Xojo.Core.Date.FromText(dateValue, Xojo.Core.Locale.Current)