A rule for date in xml - InfoPath Dev
in

InfoPath Dev

A rule for date in xml

Last post 03-30-2011 07:41 AM by Patrick Halstead. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 03-27-2011 03:53 AM

    A rule for date in xml

    Hello,

    I have a xml database and there is a given date, lets say 04-27-2011. I have a E-learning form that tells when this has to be followed, a Due date.
    Somewhere in my form i have a textbox with the current date and a textbox with the due date. In the textbox due date i have a rule that looks at the current date.
    If the due date is bigger than the current date than the due date has to turn red and when it is still to come it have to be blue.
    The data value i use for textbox current date is:today() Due date textbox is filled with the due date from XML and in tab display i use the conditional format:
    due date is less than current date (red). and due date is greater than or equal to current date (blue).

    This seems not to be working. any ideas?
    XML:
    <Duedate>04-27-2011</Duedate>

    Greetings, Marcel Michorius.

  • 03-28-2011 05:53 AM In reply to

    In your validation, try using

    translate(date1, '-', '') > translate(date2, '-', '')

    That will probably work better.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-28-2011 11:18 AM In reply to

    Sorry Jimmy, i am a little confused. Do i use this in date textbox? and do i have to filter data? Thanks in advance. Marcel.
  • 03-28-2011 05:00 PM In reply to

    I think Jimmy is suggesting you use this in place of your current rule (which from your post sounds like conditional formatting on the date field).

    Hilary Stoupa

  • 03-29-2011 01:53 AM In reply to

    I think i got it working with translate, as suggested by Jimmy and a push from Hilary.

    in text box properties date1 i went to tab display, button conditional formatting.
    The first puldown menu i have te date1 field (from my database) then the second puldown i have is less than or equel to and the last puldown i have chosen Use a Formula.
    From there i have translate (Date1, "-", "") > translate(today, "-", "")
    Then i have a Bold and color blue selected. And it seems to be working.

    But wat it means and do, i have no qlue "-",""

    Thank you

  • 03-29-2011 07:38 AM In reply to

    The translate function is removing the "-" from your dates, so that the dates are numbers like 20110301 or 20110809. Now the operator ">" knows what to do, since you are comparing two numbers....

    Hilary Stoupa

  • 03-29-2011 09:29 AM In reply to

    • pamam
    • Not Ranked
    • Joined on 03-28-2011
    • Posts 6

    Hilary,

    Can I add a few days to a date in a date picker control using rules in InfoPath 2003 SP1 rather having to write code.  And can I have the result sent to another date picker control.

    Thanks

    Mel

     

  • 03-29-2011 02:55 PM In reply to

    Aaaah, now i get it, clever solution, make it a big number and look if it is bigger, smaller or equal to. So again Hilary and Jimmy a big thanks!
  • 03-30-2011 07:41 AM In reply to

    Hi Mel,

    As you know, AddDays xpath function wasn't added until 2007...

    You could use substring to extract the day from a date and add to it. If it exceeds the number of days in the month you'd have to also extract the month and increment it. Lots of rules but no code required. You can set the value to another field with a date picker and it should work just fine.

    Best!

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.