I have a MySQL DateTime column that I need to query using C#. The problem is that when I try to query the column with the DateTime format of 'dd-MM-yyyy' it doesn't bring back any data but it does when I use the 'yyyy-MM-dd' format. I am wondering how I can convert my DateTime into that format?
Eg:
string yyyyMMdd = DateTime.Now.StartOfWeek(DayOfWeek.Monday).ToString("yyyy-MM-dd");
//Insert code to parse into yyyy-MM-dd DateTime format-
This gets the format I want in a string
, but the column is a DateTime
and every time I try to parse it, it returns back to the 'dd-MM-yyyy' format.
Man, stack overflow is so fickle. This question is different as I'm not asking how to format a DateTime into a different cultures format. I'm asking how to format a DateTime from the 'yy-MM-yyyy' to the 'yyyy-MM-dd' format.
Why the downvotes? Honestly.