I have the following code inside my remote event receiver inside a SharePoint online team site, the remote event receiver is deployed inside azure web service:-

if (i["ProjectDateSinged"] != null && properties.ItemEventProperties.AfterProperties.ContainsKey("ProjectDateSinged") && properties.ItemEventProperties.AfterProperties["ProjectDateSinged"] != null)
DateTime currentpds = (DateTime)(i["ProjectDateSinged"]);
DateTime afterpds   = (DateTime.Parse(properties.ItemEventProperties.AfterProperties["ProjectDateSinged"].ToString()));
if (currentpds.Date != afterpds.Date)
    errormessage = errormessage + "You are not authorized to update DateSigned. ";

the code is to prevent users from updating a field named ProjectDateSinged... but currently the code is failing because i am getting the same date in different amounts. for example if i have an item with ProjectDateSinged = 15 July 2020, then the (DateTime)(i["ProjectDateSinged"]) will be equal to 15/07/2020 00:00:00 which is correct, while the (DateTime.Parse(properties.ItemEventProperties.AfterProperties["ProjectDateSinged"].ToString())) will be equal to 14/07/2020 23:00:00 which is one hour before the correct value, so the validation will always fail.. any advice on how i can fix this?


  • 1
    Compare after converting both to UTC. Commented Jul 22, 2020 at 15:31
  • @SOURAVMUKHERJEE i tried to do so , but on some values the comparison will also fail
    – John John
    Commented Jul 22, 2020 at 22:54

1 Answer 1


SharePoint stores dates in UTC format. The DateTime returned by AfterProperties["ProjectDateSinged"] is in UTC format. You will need to convert the DateTime afterpds to the same format that you are using for DateTime currentpds and then compare the dates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.