mercredi 27 mai 2015

SQLite data conversion with C#

I have a text file which has the date in the format dd-month-yyyy (example, 26-Dec-2014). That data is pulled into a database. I'm using SQLite and need to convert that date format into yyyy-MM-dd. The column in SQLite for the date is TEXT format for the date. I'm using it to put the value in a datagridviewer and eventually sorting it by date. Here is some of my code in C# that has the datetimepicker value converted to yyyy.MM.dd. and then the code to

string dt1 = From_date.Value.ToString("yyyy.MM.dd");
string dt2 = To_Date.Value.ToString("yyyy.MM.dd");
string stringsqlcommand = "SELECT * from CKData"; 

SQLiteDataAdapter sda = new SQLiteDataAdapter(stringsqlcommand, con);
sda.Fill(dt);

CKData is the data table. Is there a convert function like for traditional SQL where you can take the column from the table and make it a different format? The reason I'm using SQLite is because it's a local database which I will occasionally need access to and it has to be able to cross platforms easily (used on different computers).

Aucun commentaire:

Enregistrer un commentaire