Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
javascript version of VBscript dateadd
Old 06-08-2006, 06:47 AM javascript version of VBscript dateadd
Skilled Talker

Posts: 95
Trades: 0
I think the subject says it all.

But what i'm looking for is a way to add months on to a date.

i.e i have a variable set to 60 months i want to add this to a date

for example
  • 01/01/2006 which in vbscipt i do useing dateadd which in this case would return 01/01/2011 not 01/61/2006
Is the a function or a simple way of doing this in javascript
higginbt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-08-2006, 08:35 AM Re: javascript version of VBscript dateadd
Skilled Talker

Posts: 95
Trades: 0
Ok so this is what i've come up with.

function date_addmonth(strDate,duration)
{
var mydate = strDate
var day =(mydate.substring(0,2))
var month = (mydate.substring(3,5))
var year = (mydate.substring(6,10))
alert(day)
alert(month)
alert(year)
month = Number(month) + duration
var testdate = new Date(month +"/" + day +"/" + year )
alert(testdate)
}

This function reads in a date in a string format dd/mm/yyyy i.e English date not US date. I then use substring to seperate out the day month year.

Add the duration and then build up a new date with the day month swicth round

Last edited by higginbt; 06-08-2006 at 08:36 AM..
higginbt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to javascript version of VBscript dateadd
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.99669 seconds with 12 queries