So I've been trying to figure out how to save a date time string so that it shows a colon between the hour and minute, so far everything I tried doing it just seemingly turns it into a dot.
com.Parameters.Add(new SqliteParameter("@DateAdded",
DateTime.Now.ToString("dd.MM.yyyy - HH:mm")));
Gives:
day.month.year - hour.minute
When I try another way;
com.Parameters.Add(new SqliteParameter("@DateAdded",
DateTime.Now.ToString("dd.MM.yyyy - HH/mm")));
Same thing happens:
day.month.year - hour.minute
Even tried using \ in front of ":" but it just gives me an error.
The ":" format specifier has a special meaning on custom date and time format strings as;
replace me with current culture or supplied culture time separator.
Looks like your CurrentCulture's TimeSeparator property is different than : so, you get a different result.
You can always escape it by the way with sorrunding single quotes like ':' as;
com.Parameters.Add(new SqliteParameter("@DateAdded",
DateTime.Now.ToString("dd.MM.yyyy - HH':'mm")));
It is the same as The "/" custom format specifier as well. You tested it on your second code part by the way.
As addition, SQLite saves your datetime values with ISO 8601 format if you decide to keep them as string. So, in your case, you should use it like;
com.Parameters.Add(new SqliteParameter("@DateAdded",
DateTime.Now.ToString("yyyy-MM-dd HH':'mm':'ss.fff")));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With