Click here to Skip to main content
15,905,420 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Adding number of days to a Date Pin
Alexander Wiseman21-Jul-04 3:31
Alexander Wiseman21-Jul-04 3:31 
GeneralRe: Adding number of days to a Date Pin
Ph@ntom23-Jul-04 17:48
Ph@ntom23-Jul-04 17:48 
GeneralRe: Adding number of days to a Date Pin
Alexander Wiseman25-Jul-04 3:22
Alexander Wiseman25-Jul-04 3:22 
GeneralRe: Adding number of days to a Date Pin
Ph@ntom25-Jul-04 6:16
Ph@ntom25-Jul-04 6:16 
GeneralRe: Adding number of days to a Date Pin
Ph@ntom26-Jul-04 6:12
Ph@ntom26-Jul-04 6:12 
GeneralRe: Adding number of days to a Date Pin
Alexander Wiseman27-Jul-04 8:00
Alexander Wiseman27-Jul-04 8:00 
GeneralRe: Adding number of days to a Date Pin
Ph@ntom27-Jul-04 19:40
Ph@ntom27-Jul-04 19:40 
GeneralRe: Adding number of days to a Date Pin
Alexander Wiseman28-Jul-04 4:31
Alexander Wiseman28-Jul-04 4:31 
Hey,

I have looked through your code and discovered why the month is being decreased by 1. You were exactly right when you said that the getMonth() function returns the zero-based index of the month. Your formatting functions assume a one-based index of the month, which means that the when you call FormatDate after the call to AddDayToDate, the month gets set back by 1 (July becomes June, in your test scenario).

Fortunately, there is an easy way to fix this and I have tested it to make sure it works. You need to modify the AddDayToDate function to add one to the month returned by getMonth. Below you will find the modified version of AddDayToDate. Copy it into your code and it should work fine.

// Definition of AddDayToDate
function AddDayToDate(plandate, days)
{
    var gCurrentDate = new Date(plandate);

    var newDate = DateAdd(gCurrentDate, parseInt(days,10), 
    parseInt(0,10), 
    parseInt(0,10)); 

    var year = newDate.getFullYear() ; 

    //The changed line: note the +1 to get the month in a one based index
    var month = newDate.getMonth() + 1 ;

    var date = newDate.getDate() ;

    return date + "/" + month + "/" + year ;
}


Hope that helps! Let me know if it still doesn't work. Also, I haven't had a chance, but I plan to work on the DateVariance function. I already know how to go about it, so it will just be a matter of sitting down and writing the code when I have a free moment.

Sincerely,
Alexander Wiseman
GeneralRe: Adding number of days to a Date Pin
Ph@ntom30-Jul-04 18:57
Ph@ntom30-Jul-04 18:57 
GeneralRe: Adding number of days to a Date Pin
Alexander Wiseman2-Aug-04 7:15
Alexander Wiseman2-Aug-04 7:15 
GeneralCalling Web Services from a web page Pin
NiteShade19-Jul-04 6:36
NiteShade19-Jul-04 6:36 
GeneralRe: Calling Web Services from a web page Pin
VenkatFor.NET21-Jul-04 8:08
VenkatFor.NET21-Jul-04 8:08 
GeneralRe: Calling Web Services from a web page Pin
mysorian11-Aug-04 11:41
professionalmysorian11-Aug-04 11:41 
GeneralLocalHost and Browser Pin
ohdil16-Jul-04 8:41
ohdil16-Jul-04 8:41 
GeneralRe: LocalHost and Browser Pin
Javier Lozano18-Jul-04 17:01
Javier Lozano18-Jul-04 17:01 
GeneralRe: LocalHost and Browser Pin
ohdil22-Jul-04 13:40
ohdil22-Jul-04 13:40 
GeneralRe: LocalHost and Browser Pin
Javier Lozano22-Jul-04 14:18
Javier Lozano22-Jul-04 14:18 
GeneralGarbage Collection in JS Pin
abc87616-Jul-04 0:15
abc87616-Jul-04 0:15 
GeneralAWS Report for OpenListing Pin
Sumit Kapoor15-Jul-04 21:24
Sumit Kapoor15-Jul-04 21:24 
GeneralRe: AWS Report for OpenListing Pin
zahedonline30-Oct-08 3:41
zahedonline30-Oct-08 3:41 
GeneralHere's a curly one... Pin
Anonymous15-Jul-04 20:20
Anonymous15-Jul-04 20:20 
GeneralRe: Here's a curly one... Pin
Javier Lozano18-Jul-04 17:00
Javier Lozano18-Jul-04 17:00 
Generalthe selectList can't make selected in Netscape... Pin
cool_man15-Jul-04 17:10
cool_man15-Jul-04 17:10 
QuestionCSS Borders Always White??? Pin
Josh Koppang15-Jul-04 12:57
Josh Koppang15-Jul-04 12:57 
AnswerRe: CSS Borders Always White??? Pin
Andrew Quinn AUS15-Jul-04 22:03
Andrew Quinn AUS15-Jul-04 22:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.