last day (15 days later) » 

12:23
1
A: codeigniter fetching date by comparing date in sql table not working

DaveUse the SQL date function to look at only the date portion of the column. $this->db->where("DATE(txndate) <= $sid OR DATE(txndate) => $sid");

ZNO
ZNO
i tried this, but still i get empty data, i even tried it like this $this->db->where("DATE(txndate)", $sid);
If you are trying to look for things within a certain date range then you need a single WHERE to check the date range in one shot. I modified my answer to reflect that.
ZNO
ZNO
i tried this, but it gives me site cant be reached error
That sounds completely unrelated.
ZNO
ZNO
the error came when i added this where statment
12:23
Adding that would not have caused your site to not be able to be reached.
ZNO
ZNO
i commented the where then it works, the where is casuing issue
Try including the WHERE as part of the actual select statement.

$this->db->select('userid, roll, amount, txnnumber, bankref, txntype, txndate, authstatus, feetype WHERE DATE(txndate) <= $sid OR DATE(txndate) => $sid');
ZNO
ZNO
same issue,
This site can’t be reachedThe webpage at https://badrukaonline.com/feepayment/admin/homecontroller/downloadpayment might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_RESPONSE
Again, that has nothing to do with the change you made .... almost impossible actually unless you also did something else .... at the worse you would get a PHP error of some sort if it were incorrect.
ZNO
ZNO
when i am removing this where, i gett all data in the table correctly
i also have a doubt, my input type date is like mm/day/year, but in table its like day/month/year
12:30
well that was an important piece of information. It's not a date in the database then. The SQL format for dates is yyyy-mm-dd .. is the column varchar?
ZNO
ZNO
yes, the column is varchar
and the date is like for example: 16-11-2022 17:28:41
sigh ... you have to do all sorts of gymnastics then
ZNO
ZNO
:(
that's different than what you said it was
is it dd-mm-yyyy or mm/dd/yyyy?
ZNO
ZNO
in my input search box its mm/dd/yyyy
in database dd-mm-yyyy
please give me 10mins, urgent washroom :|
12:45
$sid is the value coming from your search box?
13:04
$this->db->select('userid, roll, amount, txnnumber, bankref, txntype, txndate, authstatus, feetype WHERE UNIX_TIMESTAMP(CONCAT(SUBSTR(txndate,-4),SUBSTR(txndate,4,2),SUBSTR(txndate,1,2))) <= $entered_date OR UNIX_TIMESTAMP(CONCAT(SUBSTR(txndate,-4),SUBSTR(txndate,4,2),SUBSTR(txndate,1,2))) => $entered_date');
try that .... that converts both the entered date and the date in the database to a unix timestamp which is the only "safe" way to compare dates without them being in a proper timestamp format in the database
$this->db->select('userid, roll, amount, txnnumber, bankref, txntype, txndate, authstatus, feetype WHERE UNIX_TIMESTAMP(CONCAT(SUBSTR(txndate,7,4),SUBSTR(txndate,4,2),SUBSTR(txndate,1,2))) <= $entered_date OR UNIX_TIMESTAMP(CONCAT(SUBSTR(txndate,-4),SUBSTR(txndate,4,2),SUBSTR(txndate,1,2))) => $entered_date');
Use that 2nd one .... I forgot that you sand the value in the DB had a time too
 
4 hours later…
ZNO
ZNO
16:53
sorry, i the electricity came just 30mins back
i tried this, still i get the same issue, page cant be reached
$originalDate = $sid;
$newDate = date("d-m-Y", strtotime($originalDate));
$this->db->like("txndate", $newDate);
is this ok?

last day (15 days later) »