Below is my code
var result =
(from SV in Tbl
where (DateTimeOffset.Parse(SV.FieldName) >= DateTimeOffset.Parse(StartDate)
&& DateTimeOffset.Parse(SV.FieldName) <= DateTimeOffset.Parse(EndDate))
group SV by 1 into SVgrp
select new { Count = SVgrp.Sum(p => p.Count) }).ToList()
The value of SV.FieldName = '19-06-2015'
, StartDate = '2015-09-20T00:00:00Z'
, EndDate = '2015-10-21T23:59:59Z'
On my development machine, this code works perfectly whereas on my server, its giving me error String was not recognized as a valid DateTime
Both my machines have date format set as English(India), Location as India and Timezone set as UTC.
I tried adding CultureInfo.InvariantCulture
on all four Parse methods, but the error did not go.
Why am I getting this error on server only? How can it be solved?