>>Can someone show me the Java code needed to compare two dates that the user enters MM/DD/YYYY and ensure that one is not greater than another. So I have two date fields on a form and want to ensure that the second date is not greater than the first date and display a message to the user that it is an error.
>>
>>TIA
>
>This should work:
>
function checkDates(date1Str, date2Str)
>{
> var date1 = new Date(date1Str.substring(6,10),
> date1Str.substring(0,2)-1,
> date1Str.substring(3,5));
> var date2 = new Date(date2Str.substring(6,10),
> date2Str.substring(0,2)-1,
> date2Str.substring(3,5));
>
> if (date1.valueOf() > date2.valueOf())
> alert('Date Start cannot be greater than Date End');
>
>}
>With the assumption that the dates will always be in mm/dd/yyyy format. HTH
That did it. Thank you very much.
Bret Hobbs
"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope