I have a database with date in DD-MM-YY and i would need it to convert to YYYY-MM-DD so it could be used for date manipulation? Does anyone have any idea how it could be done with sqlite query?
Asked
Active
Viewed 1,104 times
0
-
first of all, is it in an mobile application? If yes, how do you stack it into your sqlite db? – sander338 Mar 15 '16 at 08:46
-
Hi, no it is on desktop, i solved it with string function, telling sqlitite what is year, what is month and what is date. then i updated new values. Thanks. – mssqlw Mar 17 '16 at 17:34
1 Answers
0
I know the comments say you solved your issue, but for the benefit of others coming across this...
It would depend on the type of database where your original DD-MM-YY
date was stored as to how to grab it. It would not be SQLite, since SQLite stores it as YYYY-MM-DD HH:mm:ss
(http://sqlite.org/lang_datefunc.html), as you said you needed. But let's say you have a C# application that can reach in and grab your original date as DateTime badDate
:
string goodDateString = badDate.ToString("YYYY-MM-DD HH:mm:ss");
string sql = "INSERT INTO MySQLiteTable (MyDateColumn) VALUES ('" + goodDateString + "')";
And then you use that sql
with a SQLiteCommand
and your connection string (path to your SQLite DB) to update SQLite.

vapcguy
- 7,097
- 1
- 56
- 52