The field TxnDate has a datetime type definition.
Why this works smoothly
$phql = 'SELECT SUM(Subtotal + SalesTaxTotal) as TotalVentas FROM invoice WHERE TxnDate >= "2018-01-01" AND TxnDate <= "2018-03-31"' ;
And this does not.
$iniFecha = '2018-01-01';
$finFecha = '2018-03-31';
$phql = 'SELECT SUM(Subtotal + SalesTaxTotal) as TotalVentas FROM invoice WHERE TxnDate >= ' . $iniFecha . ' AND TxnDate <= ' . $finFecha ;
And this does not too.
$phql = 'SELECT SUM(Subtotal + SalesTaxTotal) as TotalVentas FROM invoice WHERE TxnDate BETWEEN ' . $iniFecha . ' AND ' . $finFecha ;