How to use SUBSTRING in query

How to use SUBSTRING in query

misteammisteam Posts: 48Questions: 17Answers: 0

How to use SUBSTRING something like this:

Thank you in advance!

Answers

  • misteammisteam Posts: 48Questions: 17Answers: 0

    Hi Sir @allan, Thanks

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    I believe your 0 should actually be a 1. Testing it locally like that allows it to work.

    See also the MySQL documentation which states:

    For all forms of SUBSTRING(), the position of the first character in the string from which the substring is to be extracted is reckoned as 1.

    Allan

  • misteammisteam Posts: 48Questions: 17Answers: 0

    We got it sir @allan, this one is working:

    $q->and_where( 'SUBSTR(date_and_time_received,1,10)',$GLOBALS["date_now"], '=' );

This discussion has been closed.