A
A
Alexey2016-03-15 19:27:06
PHP
Alexey, 2016-03-15 19:27:06

How to compare the strings that store the date in $arFilter with CIBlockElement::GetList?

We have an infoblock with a "String" type property, let's call it DAT. It stores !date! of the form xx.xx.xxxx It is
necessary to make a selection of elements with the value of this property greater than the current day. Due to certain reasons, the field type cannot be changed.
$arSelect = Array("ID");
$arFilter["IBLOCK_ID"] = $id;
$arFilter["ACTIVE"] = "Y";
blah blah blah next
$arFilter[">PROPERTY_DAT"] = date('dmY');
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
But! For php 02/15/2016 > 03/10/2016
We cannot get PROPERTY_DAT in advance and convert, since in practice the request is more complex and it is necessary to get exactly 50 elements according to our condition, and not 50 elements, which we will process and remove unnecessary ones and get, for example, 45.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-03-16
@rixaman

I wrote the code for you, and then I read that you have a string field.
Create a second field with a date, copy the values ​​\u200b\u200bto there when the first field changes, you get two fields, one type is a string, the other is a date. And use this second field

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question