I have an app which collects data from a Google API
. When im sending a query to the API it only accepts date as string format yyyy-MM-dd
and that's fine. For that reason I'm converting this DateTime variable to string format yyyy-MM-dd
so the API accepts my request. I'm parsing DateTime to string as this will be a part of a large MVC application and I would like to stick with DateTime regarding data that concerns dates. In the case below start
will return a date like eg: 2014-03-20
when I'm sending the request to the API.
Console.WriteLine("Enter StartDate! (yyyy-MM-dd)");
var start = Console.ReadLine();
var StartDate = DateTime.ParseExact(start, "yyyy-MM-dd", CultureInfo.InvariantCulture);
I would like to sort the dates that are returned by year, start will return StartDates as string yyyy-MM-dd from a list of dates. Somehow i need to apply some logic saying yyyy = year
. Is there a standard procedure for this?