Subtract 2 dates where one is saved as text

0

I wish to obtain the total sum of the days from the date of period 25-06-2018.
My problem is that the period date can not be modified and added by a third part of a form and the format is:

Tabla periodo 
id periodo1                   id
1  del 25 de Junio del 2018   varchar(50)

Tabla asistencias
id asistio2                   id
1  26-06-2018                 date
2  27-06-2018
3  28-06-2018
4  29-06-2018

my php queries are:

$periodo = sqlsrv_query($conn, "SELECT TOP 1 periodo1 FROM periodo ORDER BY idp DESC");
 if($a=sqlsrv_fetch_array($periodo)) {
   $ultimoPeriodo=$a['periodo1'];
} 

$asist=sqlsrv_query($conn, 
"SELECT asistio2 FROM asistencias WHERE asistio2 > $ultimoPeriodo");
if($d=sqlsrv_fetch_array($asist)){
   $asist_suma+=date_format ($d['asistio2'], 'd-m-Y');
}

As I can not work subtracting text to date I would like to know what method I could use

    
asked by claus 27.07.2018 в 21:39
source

1 answer

1

try this!

<?php
// Delimiters may be slash, dot, or hyphen
$date = "26-06-2018 ";
list($month, $day, $year) = split('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year<br />\n";
?>
    
answered by 27.07.2018 в 23:00