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 :
Microsoft Dynamics CRM (Archived)

Date field with today's date

(0) ShareShare
ReportReport
Posted on by

Hello,

I would like to have a field that will display the current date at any given time, effectively the same as having the TODAY() function in Excel. Is there a way to do that without script?

Many thanks,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sean K Profile Picture
    1,537 on at

    Hi Maggie,

    You could achieve this with a Calculated field.

    First create a new field with a Field Type of Calculated

    2.-Edit.png

    Then click Edit next to Field Type, leave the condition blank and for the action have it as "Set Todays Date to Now()"

    2.-Edit.png

    Now place the field on your form and when you open the form it will show todays date

    3.-Date.JPG

  • Community Member Profile Picture
    on at

    Hi Sean,

    Thanks for that.

    It appears as if calculated fields don't work in business rules. Is there a way to get today's date without a calculated field?

    I would like to use today's date in a business rule that will set as business required another field based on whether a record was created 14 days or prior to today.

    Many thanks,

    Maggie

  • Suggested answer
    razdynamics Profile Picture
    17,308 User Group Leader on at

    Hi Maggie, You can use a Realtime Workflow

    Set the Executin Date and Time of workflow and insert it into required field.

    - add update record step into workflow

    - go into Properties

    - add Execution date and Time into Required date Field.

    when the workflow runs it inserts the current Date and Time into this field.

    I Hope this helps, Kindly tick 'Yes' to verify :)

    Best Wishes, Raz

  • Mahendar Pal Profile Picture
    45,095 on at

    Another option to use script but it will only run when you will open entity form.

    Thanks

  • Community Member Profile Picture
    on at

    Hi Raz,

    What will trigger the workflow to run though? Will I have to run it manually everyday?

    I need the field to show the current date when someone opens the record, so this needs to change everyday.

    Many thanks,

  • Suggested answer
    Community Member Profile Picture
    on at

    Sean's solution answered your original question!

    "It appears as if calculated fields don't work in business rules. Is there a way to get today's date without a calculated field?

    I would like to use today's date in a business rule that will set as business required another field based on whether a record was created 14 days or prior to today."

    1. Create a simple DateTime field, lets call it new_todaysdate

    2. Add the below javascript as a JS web resource for your solution. Call the Web resource something like new_SetTodaysDate or whatever convention you prefer.

    function SetTodaysDateOnLoad(){
     Xrm.Page.getAttribute("new_todaysdate").setValue(Date.now());
    }

    Save, and publish.

    3. In your solutions editor, click 'Form Properties' in the entitiy's form you're working with.

    4. In Event List, add the new JS resource.

    5. In Event Handlers add the function name SetTodaysDateOnLoad 

    (Don't add brackets after the function name here)

     

    Save and publish and you have the field with today's date accessible in a business rule.

    Make sure this field is invisible in your form, or even make it immutable straight after onload and mutable again after updating with the help of a workflow.

  • Suggested answer
    Daniel at VNS Profile Picture
    on at

    Thank you PaulShore - THIS is what i was looking for!

  • Firearm Profile Picture
    on at

    Where Sean's answer will do what you need it to, it will not however display a date on the form while creating.  The calculated field will not calculate until after saving.  That goes for workflows as well.  The run "Before" option is disabled in real-time workflow.

    2_2D00_13_2D00_2017-12_2D00_52_2D00_48-PM.png

  • iruser2 Profile Picture
    2,048 on at

    i'd love to find a way to have a date field on a form that automatically populates with todays date (and can still be changed by the user) without having to save in order to trigger a work flow.  The original question does CRM have the equivalent of excel

    =TODAY()

    that it can automatically populate onto a form without saving, just be there as the form opens?

    thanks!

  • empath-e CRM Profile Picture
    1,136 on at

    Just hit upon this myself and this solution worked well for me. Thanks Sean Kelly.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans