web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Date Time field value showing 1 day behind in CRM 365 9.2

(0) ShareShare
ReportReport
Posted on by 2,667

Hi All,

I have updated title with one of date time field value in crm through console.This date field is user local behaviour & format is date only.

But when its updating its showing 1 day less for ex : date reported field has : 20/07/2021 but in title it updated with 19/07/2021.

Below code i have tried with taking adding 1 day also but dont think in this way it will work as it depends on time zone.

foreach (var enitem in completeCaseCollection)
            {
                var title = enitem.Attributes.Contains("title") ? enitem.GetAttributeValue<string>("title") : string.Empty;
                var dateReported = enitem.Contains("new_datereported") ? enitem.GetAttributeValue<DateTime?>("new_datereported") : new DateTime();
 
                string day = dateReported.Value.AddDays(1).Day.ToString("00");
                string month = dateReported.Value.Month.ToString("00");
                int year = dateReported.Value.Year;
                string updatedDate = $"{day}{month}{year}";
                int pos_RunningCounter = title.LastIndexOf("-") + 1;
                string InteractionType = title.Substring(0, title.IndexOf("-"));
                string RunningCounter = title.Substring(pos_RunningCounter, title.Length - pos_RunningCounter);
                string updatedTitle = $"{InteractionType}-{updatedDate}-{RunningCounter}";
 
                // Stage Status Update
                Entity caseUpdate = new Entity("incident");             
                caseUpdate["title"] = updatedTitle;
                if (enitem.Id != null)
                    caseUpdate.Id = enitem.Id;
                if (Service != null)
                    Service.Update(caseUpdate);
}

What could be the solution instead modifying behaviour to time zone independent. Is there any other way to do from code side to convert time  ?

Thanks,

Jharana

I have the same question (0)
  • Verified answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    Hi,

    You can try by changing datetime based on user timezone in code and to get that please refer below screen:

    https://scaleablesolutions.com/convert-date-from-utc-to-user-time-zone-using-timezoneinfo-class/

    Thanks,
    Pradeep.

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    2,667 on at

    Hi Pradeep,

    I have followed this url & above one too : www.inogic.com/.../

    its working now.Thanks.

    Thanks,

    Jharana

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans