locked
Contributing datetime values to the FIM Portal RRS feed

  • General discussion

  •   FIM Knowledge Bit

     

    Getting datetime values into the portal is a tricky thing - you need a very specific ISO8601 format with three digits of fractional precision:
    yyyy-MM-ddTHH:mm:ss.fff

    This post talks about how to do this from C# and TSQL, the two most common methods you will likely use when transforming data through the Sync Service:
    http://www.identitychaos.com/2010/01/fim-2010-contributing-datetime-values.html

    C#

    DateTime dtFileTime = DateTime.FromFileTime(csentry[strSourceAttribute].IntegerValue);
    // Convert to UTC, format string using custom format similiar to round trip "o" format
    // NOTE: SQL's precision for fractional time makes storage and confirmation of anything more than two digits problematic
    //   It's better to simply enforce .000 for fractional time here since it's not absolutely critical
    mventry[strDestinationAttribute].Value = dtFileTime.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.000'");
    

    TSQL
    SELECT
    --source attribute is already datetime/datetime2
    [DATE_OF_HIRE] = CONVERT(nvarchar(30), DATEADD(hour, 7, [DATE_OF_HIRE]) , 126) + '.000'
    --source attribute needs to be converted to datetime2
    ,[TERMINATION_DATE] = CONVERT(nvarchar(30), DATEADD(hour, 7, CAST([TERMINATION_DATE] AS datetime2(7))), 126) + '.000'<br/>FROM tMyHRSource
    

    NOTE that you will need to adjust your TSQL code to account for your timezone.

    Once you convert these values into strings within the Sync Service you can export them directly through the FIM MA to any datetime datatype.

    Brad Turner, ILM MVP - Ensynch, Inc - www.identitychaos.com

     

      Go to the FIM Knowledge Bit Collection
    Thursday, March 11, 2010 5:01 PM