Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

OlderThanXHours and the current time

Posted on by 205

I created a QueryExpression with one of the Conditions set to ("dev_lastremarketingtime", ConditionOperator.OlderThanXHours, 1); 

The intent is the retrieve multiple records that are an hour after the value of dev_lastremarketingtime.

There are records in the table that meet this criterion, however, they are not returned. When I examine the record (RetrieveMultiple of a specific record this time) it seems that the times used for comparison are not consistent. 

For example, when viewing the account record in question, the dev_lastremarketingtime's value as shown on the account form is 5/17/2017 8:57 PM. the internal is time 5/18/2017 12:57:27 AM.  The wall clock at the time of the test shows 5/17/2017 10:38:11 PM (or 5/18/2017 2:38:11 AM UTC). This record should have been returned by the query (the current time is more than one hour after the value of dev_lastremarketingtime)

If I wait a few hours and run my app again, the expected records are retrieved.

It seems, therefore, that the Query expression with the ConditionOperator.OlderThanXHours is comparing the current Eastern Daylight time with the record's UTC time. 

How can I get this query to compare the same time zones (I don't think it matters which one)?

(My Personal options include the setting for Eastern Time

*This post is locked for comments

  • moshe raab Profile Picture
    moshe raab 205 on at
    RE: OlderThanXHours and the current time

    thank, I think your recommendation worked

  • Verified answer
    Chadi Tannous Profile Picture
    Chadi Tannous 1,037 on at
    RE: OlderThanXHours and the current time

    can you try to do on or before  your current date  minus one hour

  • moshe raab Profile Picture
    moshe raab 205 on at
    RE: OlderThanXHours and the current time

    that is not practical. I am doing a query for any record whose timer (dev_lastremarketingtime) is more than an hour old, regardless of the current time. I am comparing the time in the record to an hour later, but is not related to the current time

    (I am using a console app) 

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: OlderThanXHours and the current time

    Try to use older than a specific time instead. If you are using query expression inside a plugins etc. you can anyway manipulate the datetime.now with the hour difference and pass to the query.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans