I need to calculate the exact time that a certain record has to be analyzed.
Each record has a range where it can be parsed, and a maximum value in hours for term p>
Example
Endtime=Dateregistration+Term=12/26/201404:24:31
ButIneedthetimeoutofrangetobeignored,ie:
- Day25wouldbecountedonly01:35:29becausetherangeisuntil10:00pm
- Wouldcountbackfrom08h,finishingtheexacttimeas12/26/201414:24:31
Mycurrentsolutionisloop
foreachrecord:
$incremento=0$cadastro="26/12/2014 04:24:31"
$intervalo_inicial = 8
$intervalo_final = 10
$prazo = 8
while ($incremento <> $prazo) {
if ($cadastro >= $intervalo_inicial) and ($cadastro <= $intervalo_final) {
$incremento += 1
}
// adiciona 1 hora
$cadastro = date($cadastro, strtotime('1 hour'));
}
However, calculating 100,000 records makes the task very slow. Any type of solution is valid, database, formula, logic ..