Is it possible to somehow compare the date in this form: 2011-12-27 (гггг-мм-дд) directly in the request, for example, only those records that have a field with the date from 2011-07-20 to 2011-12-27 ? Or just checking through the cycle of all records? Tell me please)

    2 answers 2

     SELECT * FROM tbl WHERE `date_fld` BETWEEN '20.07.2011' AND '27.12.2011' 
    • Thanks, I will try - iproger
    • Thanks, it works))) - iproger
    • Pre-Holiday Miracles!)) - Vitaly Kustov

    It is in this format (by the way, VARCHAR ?) That under these conditions it can be compared as a string

     SELECT * FROM table WHERE `date`>'2011-07-20' AND `date`<'2011-12-27' 

    If this can still be done, I would still recommend to put the field type TIMESTAMP (well, or INT and fill it with unix_timestamp 'om)

    • The fact is that I fill the field not with me, but with joomla, component virtuemart, there I added an additional field "departure date", and there everything is in one table, if I put the type TIMESTAMP, then the text can no longer be driven there. Type field char at me) Thanks, I will try - iproger
    • Ah, well, yes, there such shamanism is a common thing. In the last site I got vmart and I left one basket from him, the rest on com_php)) - Sh4dow
    • Just about) Don't be offended, I’ll put a tick on Vitaly Kustov, because He answered first, but I put my fingers to you both) - iproger