Experts, Can anyone explain me why I am getting 1 day less From a Date Only picker in Item updating event receiver ... this happens for After properties value.
Basically I am trying to validate whether expiry date field is having value less than current date ...it works when actually date set is less than current date, but it does not allow if expiry date set is current date.This is happening because Expiry date set returns 1 day less as after value in item updating event...
SPListItem item = properties.ListItem; SPFieldDateTime cf = (SPFieldDateTime)item.Fields["Expiry Date"]; string beforeDataTimeStr = cf.GetFieldValueAsText(item["Expiry Date"]); DateTime dtBefore = DateTime.Parse(beforeDataTimeStr).ToUniversalTime(); DateTime dtAfter = DateTime.Parse(properties.AfterProperties["Expiry Date"].ToString()); SPWeb web = properties.OpenWeb(); SPTimeZone timeZone = web.RegionalSettings.TimeZone; dtAfter = timeZone.LocalTimeToUTC(dtAfter);
Above code also returns 1 day less for after value. I have set as GMT+9 Japan for Web and GMT+5:30 for Client.
Does any one has any remedy to it ..so that what appears on form is actually retrieved in event receivers?