Convert String to TDateTime

I would like to transform a string like: “2023-01-31-102755”
in TDateTime (FormatStyles.medium for the date and FormatStyles.Short for the time) with a result corresponding to: Jan 31, 2023 at 10:27.
What is the best treatment?

If you have MBS then ParseDateMBS /ParseDateTimeMBS is great where you know what the date format is:

If ParseDateTimeMBS(myDateFormat, myDateTime, tempDate, myLocale) Then
  Return tempDate
End If

If you don’t have MBS then one way to do it is to convert your string to SQLDateTime: “2023-01-31 10:27:55” and then use DateTime.FromString to get a DateTime then DateTime.ToString(Locale.Current, DateTime.FormatStyles.Medium, DateTime.FormatStyles.Short)

Edit: if you get stuck post your code and we can help


Thanks you but I can’t find how to display the date in Medium format (ex: 31 Janv. 2023) with MBS?

var d as date
MsgBox(d.ShortDate + " at "+ d.ShortTime) : Ok
MsgBox(LongDate + " at "+ d.LongTime) : Ok