Setting a date 5 days previous to today - InfoPath Dev
in

InfoPath Dev

Setting a date 5 days previous to today

Last post 08-03-2006 04:38 PM by Greg Collins. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-03-2006 12:58 PM

    Setting a date 5 days previous to today

    I am trying to capture the date and subtract 5 days from it. I thought that JScript would automatically roll back to a previous month automatically. My code does not seem to work, the value comes back as blank. Any ideas on what is wrong with this function?

    function showNextWeek(){
    dtNextWeek = new Date();
    dtNextWeek.setDate( dtNextWeek.getDate()-5 );
    alert( dtNextWeek );
    }

  • 08-03-2006 02:24 PM In reply to

    Re: Setting a date 5 days previous to today

    Actually, after digging and testing, this code works

    var d=new Date()
    d.setDate( d.getDate()-5 );
    var day=d.getDate()+ "/";
    var month=(d.getMonth() + 1)+ "/";
    var year=d.getFullYear();
  • 08-03-2006 04:38 PM In reply to

    Re: Setting a date 5 days previous to today

    Thanks for sharing this. If you ever make the transition to using managed code (i.e. C# or VB.NET) coding date math is much easier!
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.