Convert time to text? Date too? - InfoPath Dev
in

InfoPath Dev

Convert time to text? Date too?

Last post 01-05-2012 08:40 AM by shniggens. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 01-04-2012 02:25 PM

    Convert time to text? Date too?

    I need to get the text value of a formatted time and date, so that I can concat them in a field to later be available in a drop-down list.  I have 2 seperate fields, one for date, one for time.  I was able to successfully convert the date into another field into a mm/dd/yyyy format.  That's good enough.  But I'm only able to get a 24 hour format out of the time.

    Suggestions?

  • 01-04-2012 06:29 PM In reply to

    Re: Convert time to text? Date too?

    Hi,

    Is this post similar to what your doing? Jimmy posted some good suggestions.

    Jo-Anne Alfafara
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™
  • 01-05-2012 07:35 AM In reply to

    Re: Convert time to text? Date too?

    This formula from Jimmy worked -

    concat(substring(field1, 6, 2), "/", substring(field1, 9, 2), "/", substring(field1, 1, 4), " ", substring("0", 1, substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0) < 10), substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0), substring(field2, 3, 6), " ", substring("AP", 1 + (substring(field2, 1, 2) >= 12), 1), "M")

    Where field one is my date field and field two is my time field.  Now I just need to remove the seconds from the time. 

  • 01-05-2012 07:46 AM In reply to

    Re: Convert time to text? Date too?

    This should work for that:

    concat(substring(field1, 6, 2), "/", substring(field1, 9, 2), "/", substring(field1, 1, 4), " ", substring("0", 1, substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0) < 10), substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0), substring(field2, 3, 3), " ", substring("AP", 1 + (substring(field2, 1, 2) >= 12), 1), "M")

    Note the underlined 3 there.  That's the only part that changed.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-05-2012 07:50 AM In reply to

    Re: Convert time to text? Date too?

    Great, got it, thanks!

    Now, to convert the date text from 05/01/2012 to Wednesday, May 01, 2012.  ; )

  • 01-05-2012 08:15 AM In reply to

    Re: Convert time to text? Date too?

    Well, the qRules FormatDate command should be able to accomplish that for you, without all this fancy XPath.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-05-2012 08:40 AM In reply to

    Re: Convert time to text? Date too?

    Would that work on a drop-down list box?  

    If I am concatting the date and time into another field in a repeating table (which is where I applied your formula), and then lookup the concatted field in a drop-down list box, where should I apply the FormatDate?

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