Date formatting JScript - InfoPath Dev
in

InfoPath Dev

Date formatting JScript

Last post 01-19-2007 03:28 AM by zaphi. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-19-2007 12:11 AM

    • zaphi
    • Top 150 Contributor
    • Joined on 01-09-2006
    • Switzerland
    • Posts 82

    Date formatting JScript

    Hi,
    I have already looked for posts about date formatting, but I haven't found any answer to my problem.

    I have to take a date from a date picker und put this date in an e-mail intro. The date is written in the format "YYYY-MM-DD". I need to display the date in the format "DD-MM-YYYY" Is there an easy way to set by code (JScript) the right format of a date?

    Thanks.
    Best regards.
    Philippe
    Infopath 2007/SP2
  • 01-19-2007 02:15 AM In reply to

    Re: Date formatting JScript

    Hi,
    Here's some JScript that will give you the simpler date format from your stored XML date, try this:
    > var xdDate = XDocument.DOM.selectSingleNode("//my:Date").text // i.e: 2004-07-09T00:00:00.0000000+08:00
    > var arDate = xdDate.substr(0, 10).split("-");
    > var sDate = arDate[1] + "/" + arDate[2] + "/" + arDate[0];
    >
    > Results in sDate: 07/09/2004

    Hope this helps!
    Shilpa
    INFOPATHDEV India
  • 01-19-2007 03:28 AM In reply to

    • zaphi
    • Top 150 Contributor
    • Joined on 01-09-2006
    • Switzerland
    • Posts 82

    Re: Date formatting JScript

    Hi Shilpa
    You are great! It works very well.

    Thanks a lot.
    Philippe
    Infopath 2007/SP2
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.