Forum Moderators: open

Message Too Old, No Replies

Calculate Date Difference

simple but urgent question

         

kadnan

1:24 pm on Sep 16, 2005 (gmt 0)

10+ Year Member


Hi

sorry for asking dump question

I want to calculate different between two months,i have followinn input

From Month: e.g: 01
From YEAR:2004

to Month: e.g: 09
toYear:2005

is there any builtin javascript function to create date without asking DAY?

Thanks

jalarie

1:42 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



Diff = (toYear*12 + toMonth*1) - (FromYear*12 + FromMonth*1);

kadnan

7:20 am on Sep 17, 2005 (gmt 0)

10+ Year Member



Thanks

but i am running into other problem

if have a value like "08" and when i apply parseInt() on it,it shows 0 rather 8?why?

Thanks

-adnan

Bernard Marx

7:30 am on Sep 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Specify the radix in the 2nd arg:

alert( parseInt( "08", 10 ) )

[Still can't work out why it's zero though just now]

kadnan

8:50 am on Sep 17, 2005 (gmt 0)

10+ Year Member



i rather used eval("08"),working fine now

-adnan

jalarie

11:59 am on Sep 19, 2005 (gmt 0)

10+ Year Member



The leading zero switches the default radix to 8 instead of 10. The valid base-8 digits are 0-7, so the "08" has no valid digits other than the zero. Result is zero.