I have a Mobile Service on Azure and one of my columns (named InputDate) is set as type string. An example value is 2015-07-23T18:00:00Z (ISO 8601 format)
However, when I query this table with the following code:
List<MyTable> MyTableData = await TheTable.Where(t => t.Name == "test")
.OrderByDescending(t => t.__createdAt)
.ToListAsync();
And then when I print out the date using:
Debug.WriteLine(MyTableData[MyTableData.Count-1].InputDate);
It looks like this 07/23/2015 18:00:00 which is a completely different format and doesn't include the T/Z separators and also leads to a System.FormatException: String was not recognized as a valid DateTime. exception when I call DateTime.Parse with the date as the argument.
I'm really not sure why this would be, I know I should probably have the column set as type date, but forgetting that it's a date, as a string it should display exactly as is in Azure, or at least that's what I would like to happen.
Try converting the "DateTime" string property to a datetime with the DateTime.ParseExact static function.
For example: String strDate = "2015-07-23T18:00:00"; DateTime mydate = DateTime.ParseExact(strDate, "yyyy-MM-ddTHH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);