fecha = FormatDateTime("2003/12/25") dia = Instr(fecha, "25") MyMes = Instr(fecha, "12") anio = Instr(fecha, "2003") flag = 0 if cstr(dia) = "4" and cstr(MyMes) = "1" and cstr(anio) = "7" and cstr(mid(cstr(fecha), 3, 1)) = "/" then if len(fecha)=8 then format = "1" else format = "101" end if flag = 1 end if if cstr(dia) = "9" and cstr(MyMes) = "6" and cstr(anio) = "1" and cstr(mid(cstr(fecha), 5, 1)) = "." then format = "102" flag = 1 end if if cstr(dia) = "7" and cstr(MyMes) = "4" and cstr(anio) = "1" and cstr(mid(cstr(fecha), 5, 1)) = "." then format = "2" flag = 1 end if if cstr(dia) = "1" and cstr(MyMes) = "4" and cstr(anio) = "7" and cstr(mid(cstr(fecha), 3, 1)) = "/" then if len(fecha)=8 then format = "3" else format = "103" end if flag = 1 end if if cstr(dia) = "1" and cstr(MyMes) = "4" and cstr(anio) = "7" and cstr(mid(cstr(fecha), 3, 1)) = "." then if len(fecha)=8 then format = "4" else format = "104" end if flag = 1 end if if cstr(dia) = "1" and cstr(MyMes) = "4" and cstr(anio) = "7" and cstr(mid(cstr(fecha), 3, 1)) = "-" then if len(fecha)=8 then format = "5" else format = "105" end if flag = 1 end if if cstr(dia) = "1" and cstr(MyMes) = "4" and cstr(anio) = "7" and cstr(mid(cstr(fecha), 3, 1)) = " " then if len(fecha)=8 then format = "6" else format = "106" end if flag = 1 end if if instr(fecha,",")<>0 then if anio=0 then format = "7" else format = "107" end if flag = 1 end if if cstr(dia) = "4" and cstr(MyMes) = "1" and cstr(anio) = "7" and cstr(mid(cstr(fecha), 3, 1)) = "-" then if len(fecha)=8 then format = "10" else format = "110" end if flag = 1 end if if cstr(dia) = "9" and cstr(MyMes) = "6" and cstr(anio) = "1" and cstr(mid(cstr(fecha), 5, 1)) = "/" then format = "111" flag = 1 end if if cstr(dia) = "7" and cstr(MyMes) = "4" and cstr(anio) = "1" and cstr(mid(cstr(fecha), 3, 1)) = "/" then format = "11" flag = 1 end if if cstr(dia) = "7" and cstr(MyMes) = "5" and cstr(anio) = "1" then format = "112" flag = 1 end if if cstr(dia) = "5" and cstr(MyMes) = "3" and cstr(anio) = "1" then format = "12" flag = 1 end if if cstr(dia) = "1" and cstr(MyMes) = "0" then format = "113" flag = 1 end if if cstr(dia) = "9" and cstr(MyMes) = "6" and cstr(anio) = "1" and cstr(mid(cstr(fecha), 5, 1)) = "-" then format = "120" flag = 1 end if if flag = 0 then format = "100" end if Function checkdate(vDate) flagerror = 0 select case format case "1" dia = Mid(cstr(vDate),4,2) mes = Mid(cstr(vDate),1,2) anio = Mid(cstr(vDate),7,2) case "101" dia = Mid(cstr(vDate),4,2) mes = Mid(cstr(vDate),1,2) anio = Mid(cstr(vDate),7,4) case "10" dia = Mid(cstr(vDate),4,2) mes = Mid(cstr(vDate),1,2) anio = Mid(cstr(vDate),7,2) case "110" dia = Mid(cstr(vDate),4,2) mes = Mid(cstr(vDate),1,2) anio = Mid(cstr(vDate),7,4) case "102" dia = Mid(cstr(cstr(vDate)),9,2) mes = Mid(cstr(cstr(vDate)),6,2) anio = Mid(cstr(cstr(vDate)),1,4) case "111" dia = Mid(cstr(cstr(vDate)),9,2) mes = Mid(cstr(cstr(vDate)),6,2) anio = Mid(cstr(cstr(vDate)),1,4) case "2" dia = Mid(cstr(vDate),7,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),1,2) case "11" dia = Mid(cstr(vDate),7,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),1,4) case "3" dia = Mid(cstr(vDate),1,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),7,2) case "103" dia = Mid(cstr(vDate),1,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),7,4) case "4" dia = Mid(cstr(vDate),1,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),7,2) case "104" dia = Mid(cstr(vDate),1,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),7,4) case "5" dia = Mid(cstr(vDate),1,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),7,2) case "105" dia = Mid(cstr(vDate),1,2) mes = Mid(cstr(vDate),4,2) anio = Mid(cstr(vDate),7,4) case "112" dia = Mid(cstr(vDate),7,2) mes = Mid(cstr(vDate),5,2) anio = Mid(cstr(vDate),1,4) case "12" dia = Mid(cstr(vDate),5,2) mes = Mid(cstr(vDate),3,2) anio = Mid(cstr(vDate),1,4) end select if not isNumeric(dia) then flagError=1 if not isNumeric(mes) then flagError=1 if not isNumeric(anio) then flagError=1 if len(vDate) <> 10 and (cstr(format) = "100" or cstr(format) = "101" or cstr(format) = "102" or cstr(format) = "103" or cstr(format) = "104" or cstr(format) = "105" or cstr(format) = "110" or cstr(format) = "111") then flagError = 1 if len(vDate) <> 8 and (cstr(format) = "1" or cstr(format) = "2" or cstr(format) = "3" or cstr(format) = "4" or cstr(format) = "5" or cstr(format) = "10" or cstr(format) = "11" or cstr(format) = "112") then flagError = 1 if len(vDate) <> 6 and cstr(format) = "12" then flagError = 1 if len(anio)<>4 and len(anio) <> 2 then flagError=1 if flagError=0 then if cint(mes) < 1 or cint(mes) > 12 then flagError=1 end if if cstr(mes)="01" or cstr(mes) = "03" or cstr(mes) = "05" or cstr(mes) = "07" or cstr(mes)= "08" or cstr(mes) = "10" or cstr(mes) = "12" then if cint(dia) < 1 or cint(dia) > 31 or len(dia) <> 2 then flagError=1 end if end if if cstr(mes) = "02" then if cint(dia) < 1 or cint(dia) > 28 or len(dia) <> 2 then flagError=1 end if end if if cstr(mes) = "04" or cstr(mes) = "06" or cstr(mes) = "09" or cstr(mes) = "11" then if cint(dia) < 1 or cint(dia) > 30 or len(dia) <> 2 then flagError=1 end if end if end if checkdate = flagerror End Function Function msgboxdate() select case format case "100" formatdate = "Mon dd yyyy" case "101" formatdate = "mm/dd/yyyyy" case "102" formatdate = "yyyy.mm.dd" case "103" formatdate = "dd/mm/yyyy" case "104" formatdate = "dd.mm.yyyy" case "105" formatdate = "dd-mm-yyyy" case "106" formatdate = "dd mm yyyy" case "107" formatdate = "Mon dd,yyyy" case "110" formatdate = "mm-dd-yyyy" case "111" formatdate = "yyyy/mm/dd" case "112" formatdate = "yyyymmdd" case "113" formatdate = "dd Mon yyyy" case "120" formatdate = "yyyy-mm-dd" case "0" formatdate = "Mon dd yy" case "1" formatdate = "mm/dd/yy" case "2" formatdate = "yy.mm.dd" case "3" formatdate = "dd/mm/yy" case "4" formatdate = "dd.mm.yy" case "5" formatdate = "dd-mm-yy" case "6" formatdate = "dd mm yy" case "7" formatdate = "Mon dd,yy" case "10" formatdate = "mm-dd-yy" case "11" formatdate = "yy/mm/dd" case "12" formatdate = "yymmdd" case "13" formatdate = "dd Mon yy" case "20" formatdate = "yy-mm-dd" end select msgbox "Date format must be "+formatdate, 16 End Function Function CompareDate(date1, date2) select case format case "1" dia1 = Mid(cstr(date1),4,2) mes1 = Mid(cstr(date1),1,2) anio1 = Mid(cstr(date1),7,2) case "101" dia1 = Mid(cstr(date1),4,2) mes1 = Mid(cstr(date1),1,2) anio1 = Mid(cstr(date1),7,4) case "10" dia1 = Mid(cstr(date1),4,2) mes1 = Mid(cstr(date1),1,2) anio1 = Mid(cstr(date1),7,2) case "110" dia1 = Mid(cstr(date1),4,2) mes1 = Mid(cstr(date1),1,2) anio1 = Mid(cstr(date1),7,4) case "102" dia1 = Mid(cstr(cstr(date1)),9,2) mes1 = Mid(cstr(cstr(date1)),6,2) anio1 = Mid(cstr(cstr(date1)),1,4) case "111" dia1 = Mid(cstr(cstr(date1)),9,2) mes1 = Mid(cstr(cstr(date1)),6,2) anio1 = Mid(cstr(cstr(date1)),1,4) case "2" dia1 = Mid(cstr(date1),7,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),1,2) case "11" dia1 = Mid(cstr(date1),7,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),1,4) case "3" dia1 = Mid(cstr(date1),1,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),7,2) case "103" dia1 = Mid(cstr(date1),1,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),7,4) case "4" dia1 = Mid(cstr(date1),1,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),7,2) case "104" dia1 = Mid(cstr(date1),1,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),7,4) case "5" dia1 = Mid(cstr(date1),1,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),7,2) case "105" dia1 = Mid(cstr(date1),1,2) mes1 = Mid(cstr(date1),4,2) anio1 = Mid(cstr(date1),7,4) case "112" dia1 = Mid(cstr(date1),7,2) mes1 = Mid(cstr(date1),5,2) anio1 = Mid(cstr(date1),1,4) case "12" dia1 = Mid(cstr(date1),5,2) mes1 = Mid(cstr(date1),3,2) anio1 = Mid(cstr(date1),1,4) end select select case format case "1" dia2 = Mid(cstr(date2),4,2) mes2 = Mid(cstr(date2),1,2) anio2 = Mid(cstr(date2),7,2) case "101" dia2 = Mid(cstr(date2),4,2) mes2 = Mid(cstr(date2),1,2) anio2 = Mid(cstr(date2),7,4) case "10" dia2 = Mid(cstr(date2),4,2) mes2 = Mid(cstr(date2),1,2) anio2 = Mid(cstr(date2),7,2) case "110" dia2 = Mid(cstr(date2),4,2) mes2 = Mid(cstr(date2),1,2) anio2 = Mid(cstr(date2),7,4) case "102" dia2 = Mid(cstr(cstr(date2)),9,2) mes2 = Mid(cstr(cstr(date2)),6,2) anio2 = Mid(cstr(cstr(date2)),1,4) case "111" dia2 = Mid(cstr(cstr(date2)),9,2) mes2 = Mid(cstr(cstr(date2)),6,2) anio2 = Mid(cstr(cstr(date2)),1,4) case "2" dia2 = Mid(cstr(date2),7,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),1,2) case "11" dia2 = Mid(cstr(date2),7,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),1,4) case "3" dia2 = Mid(cstr(date2),1,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),7,2) case "103" dia2 = Mid(cstr(date2),1,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),7,4) case "4" dia2 = Mid(cstr(date2),1,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),7,2) case "104" dia2 = Mid(cstr(date2),1,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),7,4) case "5" dia2 = Mid(cstr(date2),1,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),7,2) case "105" dia2 = Mid(cstr(date2),1,2) mes2 = Mid(cstr(date2),4,2) anio2 = Mid(cstr(date2),7,4) case "112" dia2 = Mid(cstr(date2),7,2) mes2 = Mid(cstr(date2),5,2) anio2 = Mid(cstr(date2),1,4) case "12" dia2 = Mid(cstr(date2),5,2) mes2 = Mid(cstr(date2),3,2) anio2 = Mid(cstr(date2),1,4) end select if anio1 < anio2 then CompareDate = 1 msgbox date1 msgbox anio1 msgbox date2 msgbox anio2 else if anio1 = anio2 then if mes1 < mes2 then CompareDate = 1 else if mes1 = mes2 then if dia1 < dia2 then CompareDate = 1 else if dia1 = dia2 then CompareDate = 3 else CompareDate = 2 End if end if else CompareDate = 2 End If End If Else CompareDate = 2 End If End If End Function function DatetoServer(campo,formato) dim obj obj = document.getElementsByName(campo) fecha = trim(CStr(obj.value)) vData = "" if fecha <>"" then if IsDate(fecha) then yyyy = Year(fecha) yy = Right(yyyy,2) mm = Month(fecha) dd = Day(fecha) select case formato case "100" vData = mm&" "&dd&" "&yyyy case "101" vData = mm&"/"&dd&"/"&yyyy case "102" vData = yyyy&"."&mm&"."&dd case "103" vData = dd&"/"&mm&"/"&yyyy case "104" vData = dd&"."&mm&"."&yyyy case "105" vData = dd&"-"&mm&"-"&yyyy case "106" vData = dd&" "&mm&" "&yyyy case "107" vData = mm&" "&dd&","&yyyy case "110" vData = mm&"-"&dd&"-"&yyyy case "111" vData = yyyy&"/"&mm&"/"&dd case "112" vData = yyyy&mm&dd case "113" vData = dd&" "&mm&" "&yyyy case "120" vData = yyyy&"-"&mm&"-"&dd case "0" vData = mm&" "&dd&" "&yy case "1" vData = mm&"/"&dd&"/"&yy case "2" vData = yy&"."&mm&"."&dd case "3" vData = dd&"/"&mm&"/"&yy case "4" vData = dd&"."&mm&"."&yy case "5" vData = dd&"-"&mm&"-"&yy case "6" vData = dd&" "&mm&" "&yy case "7" vData = mm&" "&dd&","&yy case "10" vData = mm&"-"&dd&"-"&yy case "11" vData = yy&"/"&mm&"/"&dd case "12" vData = yy&mm&dd case "13" vData = dd&" "&mm&" "&yy case "20" vData = yy&"-"&mm&"-"&dd end select else end if end if DatetoServer=vData end function function DateTimetoServer(campo,formato) dim obj obj = document.getElementsByName(campo) fecha = trim(CStr(obj.value)) vData = "" if fecha <>"" then if IsDate(fecha) then yyyy = Year(fecha) yy = Right(yyyy,2) mm = Month(fecha) dd = Day(fecha) hr = Hour(fecha) mn = MInute(fecha) sc = Second(fecha) select case formato case "100" vData = mm&" "&dd&" "&yyyy case "101" vData = mm&"/"&dd&"/"&yyyy case "102" vData = yyyy&"."&mm&"."&dd case "103" vData = dd&"/"&mm&"/"&yyyy case "104" vData = dd&"."&mm&"."&yyyy case "105" vData = dd&"-"&mm&"-"&yyyy case "106" vData = dd&" "&mm&" "&yyyy case "107" vData = mm&" "&dd&","&yyyy case "110" vData = mm&"-"&dd&"-"&yyyy case "111" vData = yyyy&"/"&mm&"/"&dd case "112" vData = yyyy&mm&dd case "113" vData = dd&" "&mm&" "&yyyy case "120" vData = yyyy&"-"&mm&"-"&dd case "0" vData = mm&" "&dd&" "&yy case "1" vData = mm&"/"&dd&"/"&yy case "2" vData = yy&"."&mm&"."&dd case "3" vData = dd&"/"&mm&"/"&yy case "4" vData = dd&"."&mm&"."&yy case "5" vData = dd&"-"&mm&"-"&yy case "6" vData = dd&" "&mm&" "&yy case "7" vData = mm&" "&dd&","&yy case "10" vData = mm&"-"&dd&"-"&yy case "11" vData = yy&"/"&mm&"/"&dd case "12" vData = yy&mm&dd case "13" vData = dd&" "&mm&" "&yy case "20" vData = yy&"-"&mm&"-"&dd end select else end if if hr<10 then hr="0"&hr if mn<10 then mn="0"&mn if sc<10 then sc="0"&sc vData = vData&" "&hr&":"&mn&":"&sc end if DateTimetoServer=vData end function function parseDate(campo,tipo) dim obj 'obj = document.getElementsByName(campo) 'fecha = trim(CStr(obj.value)) fecha = campo vData = "" if fecha <>"" then if IsDate(fecha) then select case tipo case "yy" : vData = Year(fecha) case "mm" : vData = Month(fecha) case "dd" : vData = Day(fecha) end select end if end if parseDate = vData end function