Problem Formatting Dates In Textbox that reads SQLite database file


I am having a problem trying to figure out how to format a date in a textbox that is read in from a SQlite Table. The date is stored in the database in this format:


I want it to be in this format when it displays in a textbox:


I can’t seem to figure out how to do that. If I wanted to display the current date in the Textbox, I could use the code:

Dim d as new date txtDate.Text=d.ShortDate

What would the code be or how can I change the date format of the textbox if the date is already in there or before it is displayed? I can’t seem to find anything in the forums about doing that.

Any ideas would be greatly appreciated.

Use the DateValue from the DatabaseField:

[code]Dim d as date

d = recordSet.Field(“YourDateField”).dateValue

if NOT (d is nil ) Then
end if[/code]

Perfect. That worked great. Thanks Mark so much! I appreciate you taking the time to help me.

James, it works that way because you use the OS Language you are using.

Set your OS Language (and Language Settings) to English, French, German or so, and you will not get the date in the format you want it.

Every one may understand you are talking about September 18, but what about 9/12/2013 ?

Is it September 12 (USA date format) or December 9 (everywhere around the world) ?

In a recent application that involved dates, I used everywhere SQLDate (YYYY-MM-DD) and explain the users how to read it. Why ? Correct date sort and avoid user (and developer)confusions.

People: what is your opinion on that one ?

The date class in Xojo is clever, it uses the settings applied on the local computer.

A user will have set his computer to his own preferences and so if the display of a date is 9/12/2013 or 12/9/2013 the user will read it the way he is used to.

Having said that, I prefer the base SQLDate format too - this takes away any doubt as to the date. I have written my own date formatting routine that allows me to set the date in any format desired, e.g. 12Sep13, 12 September 2013 etc.

SQLdate is what we have to use if we want to sort the date (past to present, present to past) !

ProDOS (the last OS of the Apple II series excepted the GS) used DD MMM YYYY (order ?)

DD and YYYY are digits when MMM is the month name (UPPERCASE), JUN / JUL for Juin / Juillet to make the difference in French.