Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Sponsored Links

Discuss "add increment number in date" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old August 13th, 2008, 08:46 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 124
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default add increment number in date

hi
i want to write a javascript function which take a date in
YYYY-MM-DD format and return in
CYYMMDD format .
where C starts at 0 (meaning 1900-1999) and increments from there. So 2000-2099 would be 1.
3000-3099 would be 2.

how to do this .sorry for not posting any code.

Thanks a lot
__________________
Love is physical attraction and mental destruction
Reply With Quote
Sponsored Links
  #2  
Old August 13th, 2008, 09:06 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 124
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default

hi
now this is my code
Code:
function msFormatDate(vsDate)
{
if(vsDate.length > 0)
{
	vsDate = vsDate(0).text;
	return vsDate.substr(2,2) + vsDate.substr(5,2) + vsDate.substr(8,2) ;
}
else
{
	return '';
}
}
now i want to add incremented number depends on century.i meant if my date falls between 1900-1999 then my first chracter in date will be 0.and suppose my date falls between 2000-2099 then first chracter will be 1 and so on.how to accomplish this?

thanx
Reply With Quote
  #3  
Old August 13th, 2008, 09:47 AM
richyrich's Avatar
Moderator


 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 395
Thanks: 26
Thanked 32 Times in 32 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

Try this:-
Code:
function msFormatDate(vsDate){
     if(vsDate.length > 0){
           return Number(vsDate.substr(0,1))-1 + vsDate.substr(2,2) + vsDate.substr(5,2) + vsDate.substr(8,2) ;
     }else{
           return '';
     }
}
Hope that helps.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Number Manipulation AOG123 Microsoft Access 6 March 20th, 2008 01:38 PM


All times are GMT -4. The time now is 01:15 PM.



Content Relevant URLs by vBSEO 3.2.0