2

I am using FetxhXML and I want the condition to be greater than a certain number of hours.

This is what I have:

string groupby1 = "<fetch distinct='false' mapping='logical' aggregate='true'>" +
    "<entity name='opportunity'>" +
        "<attribute name='opportunityid' alias='opportunity_count' aggregate='countcolumn' />" +
        "<filter type='and'>" +
          "<condition attribute='new_leadstatus' operator='eq' value='100000000' />" +
          "<condition attribute='new_emailedtorsm' operator='eq' value='false' />" +
          "<condition attribute='ownerid' operator='not-null' />" +
          "<condition attribute='createdon' operator='last-x-hours' value='1' />" +
        "</filter>" +
        "<attribute name='ownerid' alias='ownerid' groupby='true' />" +
        "<link-entity name='systemuser' from='systemuserid' to='ownerid'>" +
            "<attribute name='internalemailaddress' alias='internalemailaddress' groupby='true' />" +
        "</link-entity>" +
    "</entity>" +
"</fetch>";

So basically on the createdon condition I would want it to be greater than 1 hour or greater than the last x hours. Is this possible?

Alex
  • 9,313
  • 1
  • 39
  • 44
  • Your condition for createdon looks correct. Are you getting an error message? – Josh Painter Sep 28 '11 at 01:00
  • It works, but it only gets the records that where created within the last 1 hour. I want to make it so it gets all the records that are greater than 1 hour. –  Sep 28 '11 at 01:13

1 Answers1

2

You'll need to use the on-or-before condition and insert your own DateTime that is one hour before the current time, like so:

string groupby1 = string.Format(@"
//snip...
<condition attribute='createdon' operator='on-or-before' value='{0}' />
//snip...
", DateTime.Now.AddHours(-1).ToUniversalTime().ToString("u"));
Josh Painter
  • 4,071
  • 21
  • 26