Converting from and to Dates

I am working on a test app for myself and I am reading some SQLite data from a db and displaying it. The dates in the db are in standard datetime format but I am using the ToText method with the FormatStyles to create more human readable data.

Is there an easy way to “undo” that formatting to recreate the original or a new datetime formatted string to then save back to the db?

use the sqldatetime property of a date data type.

dim d as new date
d.sqldatetime = my_db_date_string

I wasn’t especially clear. Sorry. I have the date and time taken from a datetime formatted string which is broken into separate strings and formatted. I no longer have the original date object, just the formatted strings.

I was curious if, since they were formatted using the FormatStyles if there was a way to return then back to the original datetime format.

Maybe use:

Dim d As New Date d.SQLDateTime = "2016-09-03 08:13:32"
So if you have Day, Month, Year, Hour, min, sec, you can do:

d.SQLDateTime = year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec

then you can use:
d.ShortDate
d.ShortTime
or whatever you need.

But if you have the formatted string like may/3/2018 you will need to create code to find each part and take that into standard date format.

That is what I was thinking as well. Just wanted to see if there was something in the docs that I was missing before I started rolling my own methods

[quote=385989:@Alberto De Poo]

d.SQLDateTime = year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec

No need for all that string concatenation:

Dim d as new Date(year, month, day, hour, minute, second)

where all parms are integers.

Thank you Julia.

I read formatted strings, that’s why I did that. Of course if the values are integers is easier that way.