Equivalent expression in xpath for 'Right' used in Excel? - InfoPath Dev
in

InfoPath Dev

Equivalent expression in xpath for 'Right' used in Excel?

Last post 11-08-2013 09:47 AM by Laura. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 11-07-2013 01:57 PM

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Equivalent expression in xpath for 'Right' used in Excel?

    Hi, I am looking for an expression I can use in xpath that works similar to the function 'Right', which starts at the far right of a string and then moves to the left a designated number of spaces. What I am trying to do is dispay just the year of a completion date. But substring(Date,6,4) did not work for me because the datetype is m/d/yyyy and I cannot change it, so my string is off on certain days.
  • 11-08-2013 08:14 AM In reply to

    Re: Equivalent expression in xpath for 'Right' used in Excel?

    How does substring(Date, 0, 5) work for you?

  • 11-08-2013 08:38 AM In reply to

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Re: Equivalent expression in xpath for 'Right' used in Excel?

    Thanks for your response, unfortunately it does not work, as it is starting at beginning of string and I need to grab the last 4 digits (2013), so start at the end and move backward 4; and the date is a field populating during rendering.
  • 11-08-2013 08:43 AM In reply to

    Re: Equivalent expression in xpath for 'Right' used in Excel?

     so just before I play your date format is d/mm/yyyy or dd/mm/yyyy

    i.e. 30/01/2013 if January

    or 30/1o/2013 if October.

    substring(now(), 0, 5) works if your date is based on now().

    Also just tested if your original date field is a date control it seems to work too. Check your original date control too.

    I've seen this where you set your original date field as a text field and changed it to a date field

  • 11-08-2013 09:01 AM In reply to

    Re: Equivalent expression in xpath for 'Right' used in Excel?

    If the actual value of the string is M/d/yyyy (not just the formatting - XML dates are always yyyy-MM-dd), you can combine a couple of substring-after...

    substring-after(datefield, "/") gets you d/yyyy

    so:

    substring-after(substring-after(datefield, "/"), "/")

    should get you just the year I think.

    Hilary Stoupa

  • 11-08-2013 09:46 AM In reply to

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Re: Equivalent expression in xpath for 'Right' used in Excel?

    i don't have the ability to change my original datetype, due to the datasource, so this does not work for me, but thanks for your help.
  • 11-08-2013 09:47 AM In reply to

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Re: Equivalent expression in xpath for 'Right' used in Excel?

    Yes, this does work! Thank you. I tried the substring-after, already but did not think to nest two functions.
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.