locked
Retrieve and filter dates with FetchXML RRS feed

  • Question

  • Hi community,

    here a curious situation. I am making some fetchxml queries from a web site. Date columns are filtered and retrieved. Web is using a valid crm user fo connect CRM. Here is the problem. If I use advance search in crm to simulate web behaviour, dates are retrieved and filtered properly. If I use this fetch xml query from my web site using this user to connect crm, date filters are not working properly and dates retrieved are not exactly the same than the ones I get on CRM. I think the problem comes from the way CRM stores dates, but I can not find a workaround to make this work properly from the web.

    Could you give me a hand on this?

    Thanks in advance

    Friday, October 19, 2012 5:11 PM

Answers

  • Hi,

    if I'm not mistaken, dates in CRM are stored in UTC format. So in your code you will have to convert the retrieved date from UTC time to your local time. In C# for example:

    var localDate = crmDate.ToLocalTime(); 

    You can take a look at this post for more info.

    Greetings,

    Pavlos


    Please mark this reply as an answer and vote it as helpful if it helps you find a resolution to your problem.
    View my latest gallery contribution here.
    Visit my blog here.




    Friday, October 19, 2012 5:16 PM

All replies

  • Hi,

    if I'm not mistaken, dates in CRM are stored in UTC format. So in your code you will have to convert the retrieved date from UTC time to your local time. In C# for example:

    var localDate = crmDate.ToLocalTime(); 

    You can take a look at this post for more info.

    Greetings,

    Pavlos


    Please mark this reply as an answer and vote it as helpful if it helps you find a resolution to your problem.
    View my latest gallery contribution here.
    Visit my blog here.




    Friday, October 19, 2012 5:16 PM
  • You were completely right! The problem was not in the filter but in the retrieved information. Applying your fix, filter and retrieved dates matches and works properly.

    Thanks!!

    Friday, October 19, 2012 6:31 PM