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)

Between operator for From DateTime and TO DateTime field in Plugin

(0) ShareShare
ReportReport
Posted on by 317

Dear All,

i want to use between operator in query expression for 2016 on premises.

I have  date field in Employee Entity - TextDate.

In the Department i have Date fields as FromDate and ToDate, if the TextDate in lies between FromDate and ToDate than i want to show the records of Employee entity .

if TextDate doesn't lies between FromDate and ToDate i dont want to show any records.

i have tried the query Expression like this and fetch XML also i tried.

QueryExpression Condition 

GreaterEqual
new ConditionExpression("FromDate ", ConditionOperator.
GreaterEqual, TextDate); 

new ConditionExpression("new_enddate", ConditionOperator.
LessEqual, TextDate);

But still it doesn't worked for me.

can Anyone guide me for the Same.

Regards,

Krishna

*This post is locked for comments

I have the same question (0)
  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Between operator for From DateTime and TO DateTime field in Plugin

    Glad it working for you Krishna. Please mark it as answer to close the thread.

  • Verified answer
    Krishna potdar Profile Picture
    317 on at
    RE: Between operator for From DateTime and TO DateTime field in Plugin

    HI,

    I have done a small mistake we have to pass query like this.

    new ConditionExpression("FromDate ", ConditionOperator.

    LessEqual, TextDate);

    new ConditionExpression("new_enddate", ConditionOperator.

    GreaterEqual, TextDate);

    it is working fine.

    Regards,

    Krishna

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Between operator for From DateTime and TO DateTime field in Plugin

    Hello,

    Share your FetchXML query here or you can test it using fetchxml builder, once tested you can use the same in your code.

    Thanks

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Between operator for From DateTime and TO DateTime field in Plugin

    Hi Krishna,

    The operator "On Or After" and "On Or Before" should work to check the dates. I just tried and it works as expectedd. It looks like the date you are passing is not in the current format hence it is returning incorrect records.

    Try to build the advanced find query with some static dates and verify if the records are coming correctly. Once done, download the fetchxml and use your date parameter (ensure the format if same as the static date).

    2821.date.png

    Hope this works

  • Krishna potdar Profile Picture
    317 on at
    RE: Between operator for From DateTime and TO DateTime field in Plugin

    HI Guido Preite,

    Yes with date fields i want to "On Or After" and "On Or Before" operators i have applied in fetch xml for the same but still its not working for me.

    Regards,

    Krishna.

  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: Between operator for From DateTime and TO DateTime field in Plugin

    with the date fields you need to use "On Or After" and "On Or Before" operators

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