How to subtract the Date minus 30 days in JScript - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to subtract the Date minus 30 days in JScript

Last post 08-06-2005 05:19 PM by Patrick Halstead. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 07-26-2005 06:48 AM

    • yuvaraj
    • Not Ranked
    • Joined on 07-09-2005
    • India
    • Posts 3

    How to subtract the Date minus 30 days in JScript

    Hi

    I wrote the JScript to subtract the number of days from <12-Jan-2005>. I am getting 13/0/2005, but actual result should be 13/12/2004.

    I am using InfoPath and JScript.

    Please provide me the sample code in JScript that, how to subtract the no of days from the date.


    Thanks & Regards
    C.G.Yuvaraj


    Yuvaraj
  • 07-26-2005 11:35 AM In reply to

    Re: How to subtract the Date minus 30 days in JScript

    You need to get the date, break it down into its component parts (year, month, date) and then subtract 30 from the date part.

    Then you need to create a new date object using the year, month and date-30 components. This will create a valid date, properly adjusting all component parts for your adjustment.

    Now you can break that new date back down into the form XML wants (yyyy-mm-dd).

    Greg Collins [InfoPath MVP]
    InfoPath Dev
  • 07-26-2005 11:28 PM In reply to

    Re: How to subtract the Date minus 30 days in JScript

    Hi,
    my problem is similar to this: I need to sum to a date 6 days but it's quite difficult if you want to take in consideration months with different number of days and also leap years....
  • 07-27-2005 10:06 AM In reply to

    Re: How to subtract the Date minus 30 days in JScript

    Tatopitta,

    The process I described above does all of those calculations for you. When you create the new 'date object', the adjustments are properly made to account for correct days of month or year, etc.

    Greg Collins [InfoPath MVP]
    InfoPath Dev
  • 08-05-2005 09:28 PM In reply to

    • egasber
    • Not Ranked
    • Joined on 08-06-2005
    • USA
    • Posts 1

    Re: How to subtract the Date minus 30 days in JScript

    OK, I think I am fairly clear on how to insert date information into an infopath form using Jscript. I am not so clear on how to take a date entered using a date picker, and working with it in Jscript. What I want to do, is to take a date of birth entered using a date picker field, and run a check to see if the date of birth is less than than 6 months old.

    Any suggestions?

    Eric Gasber
  • 08-06-2005 05:19 PM In reply to

    Re: How to subtract the Date minus 30 days in JScript

    Hi Eric,
    Once you calculate out the number of days just compare to less than 183 and set some validation based on that. Good luck.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.