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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

crm plugin get CreatedOn and update field

(0) ShareShare
ReportReport
Posted on by 395

Hi,

I wrote a plugin(early bound).

I have a dateTime field ,he is read only and I want that his value

will be DateTime.Now.Date-CreatedOn.value.Date .

How can I do it?

thanks!!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at
    RE: crm plugin get CreatedOn and update field

    Hi,

    If you're subtracting two dates, you end up with a TimeSpan object. You can get the number of days from a timespan, but you can't express that a years/months/days because the number of months depends on the day you start counting.

    If you want to subtract two dates in the plugins and save the difference in days, it would be something like:

    TimeSpan difference = DateTime.Now - entity["createdon"].Value;
    entity["my_field"] = difference.Days.ToString();


    Hope this helps! I'd appreciate if you would mark this as a Verified answer.

    Thanks,

      Aiden

  • NAOMI314 Profile Picture
    395 on at
    RE: crm plugin get CreatedOn and update field

    yes,

    I want to set current date minus myEntity.CreatedOn.value.Date.

    thanks!

  • Mahendar Pal Profile Picture
    45,095 on at
    RE: crm plugin get CreatedOn and update field

    Hi,

    Do you want to set current date to some field ??

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans