date and textbox

Hi there,

im trying to format a textbox to a date… so the user type in something like “01.12.2016” or “01.12.16”

so the best thing is to format the date when textbox lostfocus like “01.12.2016” and the db needs it like 2016-12-01 i think. How can i get this to work? On VB this is super easy cause the datepicker on xojo there isnt a standard feature like this :frowning:

ParseDate
Date.SQLDateTime

Ty but hm the links dont open here :-/

There are :
http://www.great-white-software.com/Great_White_Software/REALbasic_Code.html
https://github.com/IntelligentVisibility/CalendarTimeChooser

Commercial :
http://www.jeremieleroy.com/products/calendarview.php
http://einhugur.com/Html/Grids.html

http://documentation.xojo.com/ doesnt work anymore or is this just me?

so i can conver 01.12.2016 to 2016-12-01 with Date.SQLDateTime ?

Read the Date the user fills (but you will have hard time if the user fills 30.02.2016… so more work to avoid that),
Create a Date Class instance and fill it with the user data,
And pass to the db the date as SQLDate (UserDate.SQLDate)

Also, if your user can live in the USA or other parts of the worl, you may have troubles with its passed date: 30.03.2016 is easy, but what about 12.11.2016 ?

You can set a window with some PopupMenus:
one PopupMenu for the Days (filled based on the Month value)
one PopupMenu for the Months (1 … 12)
one PopupMenu for the Years (2001 … 2020) or a ComboBox with some pre-defined years.

A PushButton that have code that create a Date object and fill it + pass it to thd db.

so i can conver 01.12.2016 to 2016-12-01 with Date.SQLDateTime ?
Yes, using eventually ParseDate or what I wrote in the previous entry.

[quote=280115:@Sascha Mierke]http://documentation.xojo.com/ doesnt work anymore or is this just me?

so i can conver 01.12.2016 to 2016-12-01 with Date.SQLDateTime ?[/quote]

Better use a date picker. You never know what the user may come up as strange entry.

Emile’s suggestion to use popupmenus is what a lot of web sites use today.