ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

DB READ - BETWEEN TWO DATES (V5)

atanunu 18 Feb, 2017
I need the DB Read action to get records between two dates, I am having issues making this work. Kindly help

NORMAL SQL QUERY
"WHERE Payment = 1 AND id = '$a' AND Date BETWEEN '$b' AND '$c'";

I need to implement the code above in array format below:

RETURN ARRAY AS REQUIRED BY DB READ ACTION
return array(
        'Payment' => 1,
        'id' => $form->data['pcuser'],
  	'PWVTransactionDate >= ' => $form->data['pcfromactual'],
  	'PWVTransactionDate <= ' <= $form->data['pctoactual'],
);
?>

I will be very grateful
Max_admin 18 Feb, 2017
Hi atanunu,

The last line in the array is wrong, it should be => like the others, this is php array syntax.

The date supplied should be in the mysql format too, try this:
date("Y-m-d H:i:s", strtotime($form->data["date_field"]))

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
atanunu 18 Feb, 2017
Thanks sir, the date is formatted as required and as contained in the MySQL table.

I have attached a screen shot of the table with out conditions and my error should be properly using the
BETWEEN '2005-01-01 00:00:00 AM' AND '2017-02-19 00:00:00 AM'
In the return array
GreyHead 18 Feb, 2017
Answer
Hi atanunu,

Please try
<?php
return array( ": `Payment` = 1 AND ( `PWVTransactionDate` BETWEEN '{$form->data['pcfromactual']}' AND '{$form->data['pctoactual']}' )" );
?>
Bob
atanunu 18 Feb, 2017
Thanks Sir,

You are amazing! the solution was awesome and works exactly as I needed.
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com