DateTime Picker: Getting DateTime data

Hello Friends

I am working on a desktop project using Xojo Mac 2023 Version 2 on a Macbook M1.
First time working with the DateTime Control, as the non-graphical one is ugly and way too small and the graphical one, while much cuter, takes up a lot of room on a form. I have the control set to “Date Only”.
Deciding on the cute but large option, I got data out of it to send to a text field:

Var myDate as String=DatePickerControl1.SelectedDate.ToString
TextField1.Text=myDate

This puts a kind of “Display” DateTime value in the receiving text field. But it has “at” between the date and time, obviously to be used as a display value on a label or something (which is documented). I can kludge my way through this with a left(10) and right7) to get the date and time value, but I was wondering if there’s another way I missed. (Also the local date might mess this up).

I also provided for a way for the user to enter the date into a text field and make it reflect onto the graphical DateTime control:

Var DateString As String =TextField1.Text
Var myDate1 As DateTime = DateTime.FromString(DateString)
DatePickerControl1.SelectedDate = myDate1

This works fine, but of course if I update it from the DateTime control with the “at” inside the datetime value, I get an error and the program crashes.

So, is there something built-in that lets me eliminate the “at” or parse out the date and time?
(In this case, the values will be stored independently as a discrete Date and Time field in a MySQL database).

I know there are a lot of entries under DateTime Picker in this forum, but none of them I read addressed this particular issue AFAIK.

I don’t see a lot of real-world examples of using this control, and found nothing in the Examples except a Calendar Control that showed a few errors I could not correct. I hope the docs people could maybe do another Blog post or something that goes into somewhat more detail than the one I read today.

Thank you
fritz

There are formatting options with the ToString function. Check out the documentation for more details: DateTime — Xojo documentation

Tim

This turned out to be a little more direct for my application:
DateTextField.Text=DatePickerControl.SelectedDate.SQLDateTime

I am going to read up on date arithmetic before deciding if I have to mess around with this part of the project too much more. I seem to recall that it’s not too much different than VB. For the reports I’ll end up doing the math in SQL anyway.

Thank you very much,
fritz