Comparing Dates - InfoPath Dev
in

InfoPath Dev

Comparing Dates

Last post 09-10-2007 07:49 AM by cathy. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-07-2007 11:18 AM

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Comparing Dates

    Hi,

    I have two DateTime picker controls Date1 and Date2. How can I compare these two dates in VSTA? I need to pass some data to a text box depending on this comparision. How to do that using code?

    Thanks

     

     

  • 09-10-2007 12:46 AM In reply to

    Hello

    Please go through this link

    http://www.infopathdev.com/forums/p/1192/1911.aspx#1911

    I hope it will help you

    Kalyan G Reddy
    Infopath MVP 2007 and 2008
  • 09-10-2007 07:49 AM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    I tried the following code for my requirement. My requirement is to pass the value as "YELLOW" in a text box if the target date is with in 3 days.

    XPathNavigator GYR = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field154", this.NamespaceManager);

    XPathNavigator Date1 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field98", this.NamespaceManager);

    DateTime tempdate,today;

    tempdate = Date1.ValueAsDateTime;

    today =
    DateTime.Now;

    TimeSpan ts = tempdate - today;

    string days = ts.Days.ToString();if ((days == "3") || (days == "2") || (days== "1") || (days== "0"))

    {

    GYR.SetValue(
    "Yellow");

    }

    This code is giving me the error at line tempdate=Date1.ValueAsDateTime  as follows

    "The string '' is not a valid AllXsd value."

    Why I am getting this message?

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