Set value as datetime? - InfoPath Dev
in

InfoPath Dev

Set value as datetime?

Last post 02-17-2009 11:52 AM by geoffc. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-17-2009 08:28 AM

    Set value as datetime?

    I am doing some date calculations through code and am trying to set a couple nodes on my infopath form to these returned values. I would like to set them as datetime but I am not sure how to do that. I am currently setting them as strings. However, this is a problem because I get data validation errors since the nodes use the datetime data type. Is there a way to set them as datetime rather than converting them to strings? This is probably easier to understand by looking at my code:

    string scd2 = string.Empty;

    string scd3 = string.Empty;

    string scd = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/my:queryResults2/my:resultsRow2/my:scd", NamespaceManager).Value;

    DateTime dt = Convert.ToDateTime(scd).AddMonths(18);

    scd2 = dt.ToShortDateString();

    e.Source.SelectSingleNode("/dfs:myFields/my:scd2", NamespaceManager).SetValue(scd2);

    DateTime dt2 = Convert.ToDateTime(dt).AddMonths(18);

    scd3 = dt2.ToShortDateString();

    e.Source.SelectSingleNode("/dfs:myFields/my:scd3", NamespaceManager).SetValue(scd3);

  • 02-17-2009 11:52 AM In reply to

    nevermind, I figured this out. instead of ToShortDateString(), I used ToString("yyyy-MM-dd")
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.