Visual Basic - Necesito rutina para calcular entre horas.URGENTE!

Life is soft - evento anual de software empresarial
 
Vista:

Necesito rutina para calcular entre horas.URGENTE!

Publicado por Albert (14 intervenciones) el 27/08/2001 18:30:36
Hola foro:
Necesito una rutina o manera de calcular el tiempo (HH:MM) que hay entre dos strings ( HH:MM - HH:MM ), y a poder ser que también valide estos valores. GRACIAS. ES URGENTEEEEEEEEEE
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RTA

Publicado por Ariel (165 intervenciones) el 27/08/2001 19:18:56
Para validar si un strin es de tipo fecha utiliza la funcion IsDate..
Para restar 2 fechas utiliza datediff...

En la ayuda de VB podes obtener mas información. Cualquier duda avisame
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Necesito rutina para calcular entre horas.URGEN

Publicado por maro (83 intervenciones) el 27/08/2001 22:54:05
mira la funcion DateDiff("n", "12:23", "13:23")
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Necesito rutina para calcular entre horas.URGEN

Publicado por Albert (14 intervenciones) el 21/08/2006 00:51:35
<input type="text" name="hora_inicio" value=<valor hh:mm> onchange="Re_calcula(id del input)
<input type="text" name="hora_termino" value=<valor hh:mm> onchange="Re_calcula(id del input

esto lo dejas tal cual

function padNmb(nStr, nLen){
var sRes = String(nStr);
var sCeros = "0000000000";
return sCeros.substr(0, nLen - sRes.length) + sRes;
}

function stringToSeconds(tiempo){
var sep1 = tiempo.indexOf(":");
var sep2 = tiempo.lastIndexOf(":");
var hor = tiempo.substr(0, sep1);
var min = tiempo.substr(sep1 + 1, sep2 - sep1 - 1);
var sec = tiempo.substr(sep2 + 1);
return (Number(sec) + (Number(min) * 60) + (Number(hor) * 3600));
}

function secondsToTime(secs)
{
var hor = Math.floor(secs / 3600);
var min = Math.floor((secs - (hor * 3600)) / 60);
var sec = secs - (hor * 3600) - (min * 60);
return padNmb(hor, 2) + ":" + padNmb(min, 2) + ":" + padNmb(sec, 2);
}

function substractTimes(t1, t2)
{
var secs1 = stringToSeconds(t1);
var secs2 = stringToSeconds(t2);
var secsDif = secs1 - secs2;
return secondsToTime(secsDif);
}

function Re_calcula(larg)
{
var duracion=new Date();
total_reg = Number(document.grabar.cantidad.value); --> aqui creo input hidden donde guardo la cantidad de input horas que tengo,, ya que esto es una tabal y puedo tener muchos input

if (total_reg > 1)
{
var h_inicio=document.grabar.h_inicio[larg-1].value +':00';
var h_termino=document.grabar.h_termino[larg-1].value +':00';
document.grabar.duracion[larg-1].value=substractTimes(h_termino,h_inicio).substring(0,5); --> aqui dejo el resultado de la resta de las hors en este input, llamado duracion
}
else
{
var h_inicio=document.grabar.h_inicio.value +':00';
var h_termino=document.grabar.h_termino.value +':00';
document.grabar.duracion.value=substractTimes(h_termino,h_inicio).substring(0,5);
}

}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar