Notifications
Announcements
No record found.
Hello Everyone,
I have two DateTime fields i.e. TimeIn & TimeOut and I want to compare these two fields on the basis of "Time as well as Date" using JavaScript.
Please help..
*This post is locked for comments
Hello,
Check those links to compare two dates:
community.dynamics.com/.../compare-two-date-field-values-in-dynamics-crm-using-javascript
https://community.dynamics.com/crm/f/117/t/280706
Hi Manoj,
Please refer to the following link: www.digitalocean.com/.../understanding-date-and-time-in-javascript
Please mark this answer as verified, if helped you to resolve your issue.
On top of what Charles already suggested, you could consider using Business Rule too as they support some date time operators that might help
Business Rule
If your date time operations are a bit complex, you could also consider using a library like moment.js, please follow the links below if you are interested in knowing more about these
https://crmtipoftheday.com/398/careful-with-those-js-libraries/
https://gallery.technet.microsoft.com/scriptcenter/Momentjs-and-Dynamics-CRM-8bd3a264
Hi, you can get the values from your two fields:
var timein = Xrm.Page.getAttribute('timein').getValue();
var timeout = Xrm.Page.getAttribute('timeout').getValue();
create new Date for your dates:
var inDate = new Date(timein);
var outDate = new Date(timeout);
compare variables:
eg. if(inDate == outDate) { ... }
var timein = Xrm.Page.getAttribute ('timein'). getValue (); var timeout = Xrm.Page.getAttribute ('timeout'). getValue ();
It Works ,Thank You !
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2