InfoPath rules time different from C# time in same form? - InfoPath Dev
in

InfoPath Dev

InfoPath rules time different from C# time in same form?

Last post 02-21-2012 06:21 AM by Trevor Arter. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-21-2012 05:35 AM

    InfoPath rules time different from C# time in same form?

    Hi All

    I have a form containing both rules and code

    When the form is created it sets the creation date according to a rule in form open behaviour:

    "Set a fields value: CreatedWhen = now".

     This sets the time correctly

     

    The same form has some C# code:

    //record time date and user updated

    string s;

    DateTime now = DateTime.Now;

    s = "Updated: " + now.ToString("U",culture) + " by: " + System.Environment.UserName;

    sSetField("CommentTotalAll", s);  //This just writes the string to a text field using an XPath Navigator

     

    The trouble is that the date set by the code is one hour behind in relation to the computers time, while the time set by rules is correct. Does anyone know why this could be? (I've tried changing the culture, that made no difference)

     Thanks

    Trevor

     

  • 02-21-2012 06:00 AM In reply to

    Re: InfoPath rules time different from C# time in same form?

    Are you one timezone away from England?  The "U" format string produces UTF time so that would explain the discrepancy.  For local time, you can just use DateTime.Now.ToString().
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-21-2012 06:21 AM In reply to

    Re: InfoPath rules time different from C# time in same form?

    Yes that fixed it thanks

    I thought the U was just formatting

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.