Technology is winforms, using c#, database is SQlite.
I'm taking values from the DB, transfering them into lists, and subsequently populating a listview with those lists.
I have two columns for dates. One has values with the format of Year and month (YYYY-MM) and the other is Year and Week (YYYY-WW).
Problem:
But in the listview these values show up with slashes in between them, i.e January 2001 is written as 1/1/2001 12:00 am. The 31st week in 2002 is written as 3/1/2002 12:00 am.
I don't want the TIME or slashes in the output. (First 2 lists are the output in listview, with the errors i mentioned above. The second 2 columns are how the data is supposed to look).
What the problem is caused by: I use the DateTime datatype to store the values from these columns. Is there any datatype which will just output these values in year-month and year week format, instead of displaying slashes and time. If I try using int, the these columns don't even get read so can't use that.
Code: (Just focus on the yyyymm part)
string sql6 = "select YYMM, TotalTrans from t2 where cast(TotalTrans as int) < 1000";
SQLiteCommand command3 = new SQLiteCommand(sql6, sqlite_conn);
SQLiteDataReader reader3 = command3.ExecuteReader();
while (reader3.Read())
{
int TotalTrans;
DateTime yyyymm; //Right here:
if (DateTime.TryParse(reader3["YYMM"].ToString(), out yyyymm) && int.TryParse(reader3["TotalTrans"].ToString(), out TotalTrans))
{
YYMM.Add(yyyymm);
TotalTransIrregularities.Add(TotalTrans);
}
}