Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Datetime field issue on dynamics 365

(0) ShareShare
ReportReport
Posted on by 75

Hi,

I am retrieving all accounts data using FetchXML on a console application. When I retrieve data the Date of birth(DateTime) field retrieve is getting -1 day. e.g. If a date of birth is 19/09/1990 then on console application it shows 18/09/1990. How can I solve this problem to get the perfect date?

Thanks in advance

*This post is locked for comments

  • Verified answer
    Kiran_girase Profile Picture
    75 on at
    RE: Datetime field issue on dynamics 365

    Thanks for answering,

    My issue has been solved by putting,

    DateTime dt = (DateTime)entity.Attribute["datefield"];
    DateTime dt1 = dt.AddHours(+5).AddMinutes(+30);

    Thanks

  • Suggested answer
    ScottDurow Profile Picture
    19 on at
    RE: Datetime field issue on dynamics 365

    Exactly - time zones are tricky when working with absolute dates. Microsoft have now implemented time zone independent date fields for this kind of date - see docs.microsoft.com/.../behavior-format-date-time-field

    Hope this helps

  • Suggested answer
    Sreevalli Profile Picture
    3,256 on at
    RE: Datetime field issue on dynamics 365

    Hi,

    Its depends on system time difference with current working computer.

    eg: if it is 8hr and the your CRM field is having 18/01/19 6:00:00 then it will be on same day as it will add 8hrs and the final time would be 14:00:00. but if your field contains 18/01/19 17hrs then after adding 8hrs it would be 19/01/19 01:00:00

  • Kiran_girase Profile Picture
    75 on at
    RE: Datetime field issue on dynamics 365

    Thanks for reply Sreevalli,

    I am working on-premise CRM using VPN and sometimes date retrieve perfect and sometimes -1 of day.

  • Suggested answer
    Sreevalli Profile Picture
    3,256 on at
    RE: Datetime field issue on dynamics 365

    Hi,

    It is because of the time difference in your computer time and the CRM timzone.

    Below code will return the time difference in minutes and then you can +/- to your local time.

    public int? RetrieveCurrentUsersTimeZoneSettings(IOrganizationService service)

    {

        var currentUserSettings = service.RetrieveMultiple(

        new QueryExpression("usersettings")

        {

           ColumnSet = new ColumnSet("localeid", "timezonecode"),

           Criteria = new FilterExpression

           {

               Conditions =

           {

               new ConditionExpression("systemuserid", ConditionOperator.EqualUserId)

           }

           }

        }).Entities[0].ToEntity<Entity>();

        return (int?)currentUserSettings.Attributes["timezonecode"];

    }

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans