codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Month Start, End dates  danasegarane at 13:34 on Monday, May 05, 2008
 

Hi All,
I am using this code to get the start and end date between two dates.

[code]
function FillCurrentMonthStartAndEndDates(format)
{
var startDate=new Date();
var endDate=new Date();
var currentMonth=startDate.getMonth();//current month
startDate.setDate(1);//current month start date as object
frmHourRegistration.txtStartDate.value=formatDate(startDate,format);
var intMonths=27;
while(endDate.getMonth()==currentMonth)
{
intMonths++;endDate.setDate(intMonths);
}
endDate.setDate(0);//current month end date as object
frmHourRegistration.txtEndDate.value=formatDate(endDate,format);
}


function addZero(vNumber)
{
return ((vNumber < 10) ? "0" : "") + vNumber;
}

function formatDate(vDate, vFormat)
{
var vDay = addZero(vDate.getDate());
var vMonth = addZero(vDate.getMonth()+1);
var vYearLong = addZero(vDate.getFullYear());
var vYearShort = addZero(vDate.getFullYear().toString().substring(3,4));
var vYear = (vFormat.indexOf("yyyy")>-1?vYearLong:vYearShort)
var vHour = addZero(vDate.getHours());
var vMinute = addZero(vDate.getMinutes());
var vSecond = addZero(vDate.getSeconds());
var vDateString = vFormat.replace(/dd/g, vDay).replace(/MM/g, vMonth).replace(/y{1,4}/g, vYear)
vDateString = vDateString.replace(/hh/g, vHour).replace(/mm/g, vMinute).replace(/ss/g, vSecond)
return vDateString
}
[/code]

This works well if i pass the format as dd/mm/yyyy. But it gives the wrong result when i pass the format as dd-mm-yyyy. What i am doing wrong hear ?

Thanks in Advance
Dana








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Perl Script - File Handling.
•  Open a file from website
•  Re: to open 5 terminals from one and also execute different commands on each terminal
•  read a selected multiple line, those should match some of the values read in the files..
•  Help me please
•  Empty the contents of a file.
•  Month Start, End dates
•  show hide problem in dynamic table creation
•  Re: ASP Sendmail has huge delay - ANYONE??


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008