'************************************** ' for :Calculate the last day of the mon ' th '************************************** Copyright (c) 2000 Mike Collins. You are hearby granted the right of non-exclusive use for any reason provided that you provide this copyright message in any work that uses this code. '************************************** ' Name: Calculate the last day of the mo ' nth ' Description:Determines number of days ' in a month, with leap year check. ' By: Mike Collins (from psc cd) ' ' ' Inputs:Month and year requested ' ' Returns:Number of days in that month ' 'Assumes:Nothing ' 'Side Effects:none '************************************** Here is the VBScript Sample ---------------------------------------------- function GetLastDay( month, year ) month = month + 1 if month > 12 then month = month - 12 year = year + 1 end if Dim x x = DateAdd("d", -1, month&"/01/"&year) GetLastDay = Day( x ) end function Response.Write GetLastDay( 3, 1999 )&"<br>" Response.Write GetLastDay( 2, 1999 )&"<br>" Response.Write GetLastDay( 2, 2000 )&"<br>" ---------------------------------------------- Here is the JavaScript Sample ---------------------------------------------- function GetLastDay( month, year ) { month++; if( month > 12 ) { month -= 12; year++; } var x = new Date( month+"/1/"+year ); x = new Date( x.valueOf()-(1000*60*60*24) ); //1000*60*60*24=number of millisecs in 1 day return x.getDate(); } Response.Write( GetLastDay( 3, 1999 )+"<br>" ); Response.Write( GetLastDay( 2, 1999 )+"<br>" ); Response.Write( GetLastDay( 2, 2000 )+"<br>" );