Xojo.Core.Date (Locale) Question

I know I am missing something since “d” is always NIL for me. Any advice is seriously appreciated :slight_smile:

  Dim thisLocale as xojo.Core.Locale = xojo.core.Locale.Current
  Dim thisFormattedSQLDate as String = convertToSQLDateTime(thisDateText)
  dim d as xojo.core.date = xojo.core.date.FromText (thisFormattedSQLDate.ToText, thisLocale)

Also if I omit the “thisLocale” then “d” instantiates and it works.

Thanks!

It looks like adding a locale changes how it expects the date string to be formatted.

[code] Dim currentLocale As Xojo.Core.Locale = Xojo.Core.Locale.Current
dim date_text as text
dim d as xojo.core.date

date_text = “2016-02-20”

d = xojo.core.date.FromText(date_text) '<–Works
d = xojo.core.date.FromText(date_text, currentLocale) '<-- Doesn’t work

date_text = “2/20/2016”

d = xojo.core.date.FromText(date_text) '<-- Doesn’t work
d = xojo.core.date.FromText(date_text, currentLocale) '<–Works[/code]

[quote=248387:@Scott Griffitts]It looks like adding a locale changes how it expects the date string to be formatted.

[code] Dim currentLocale As Xojo.Core.Locale = Xojo.Core.Locale.Current
dim date_text as text
dim d as xojo.core.date

date_text = “2016-02-20”

d = xojo.core.date.FromText(date_text) '<–Works
d = xojo.core.date.FromText(date_text, currentLocale) '<-- Doesn’t work

date_text = “2/20/2016”

d = xojo.core.date.FromText(date_text) '<-- Doesn’t work
d = xojo.core.date.FromText(date_text, currentLocale) '<–Works[/code][/quote]

Scott Awesome find!!! Ill try it and thank you so much!!

It worked thank you!!

Now that I’m thinking about it, even though the documentation doesn’t spell it out, it makes sense that the function of the locale is to specify how the date text is formatted. So if you have a sqldate, you don’t really need a locale as it’s basically a universal format for a date.