C# DateTime Serialization to CST for ExactTarget SOAP API

I have contacted Exact Target support for this but they sent me here. I can’t seem to get results back from the API that match my date time filters. I think they are telling me that my DateTime needs to be serialized to look something like this for CST: 2014-07-22T00:00:00.000-06:00 but I can’t figure out how to get this to happen.

If my request XML looks like this:

        <Filter xsi:type="ComplexFilterPart">
           <LeftOperand xsi:type="SimpleFilterPart">
              <Property>CurrentStatus</Property>
              <SimpleOperator>equals</SimpleOperator>
              <Value>Held</Value>
           </LeftOperand>
           <LogicalOperator>AND</LogicalOperator>
           <RightOperand xsi:type="SimpleFilterPart">
              <Property>CreatedDate</Property>
              <SimpleOperator>greaterThan</SimpleOperator>
              <DateValue>2014-07-25T04:52:22.674964</DateValue>
           </RightOperand>
        </Filter>

I get results which are lower than the DateTime provided in the filter such as:

<CreatedDate>2014-07-24T23:25:40.46</CreatedDate> 

I tried converting to the timezone they have asked for and have tried playing around using different DateTimeKinds but have had no luck with anything. For example:

        TimeZoneInfo centralZone = TimeZoneInfo.CreateCustomTimeZone("CST No Daylight Savings", TimeSpan.FromHours(-6), "CST No Daylight Savings", "CST No Daylight Savings");

        lastHardBounceDate = TimeZoneInfo.ConvertTime(DateTime.Now.AddHours(-1), centralZone);

Does anyone have any information for how to resolve this?

Answer

So i know they tell you not to, but have you tried using the string value on the filter?

r.Filter = new SimpleFilterPart{
        Property = "CreatedDate",
        SimpleOperator = SimpleOperators.greaterThan,
        Value = new []{"2014-01-14 00:00:00"}
    };

The above works as expected for me with no need to add any timezone information.

Attribution
Source : Link , Question Author : Wiredness , Answer Author : Scott Pucket

Leave a Comment