I
I
Ingvar Von Bjork2019-07-23 10:48:36
1C-Bitrix
Ingvar Von Bjork, 2019-07-23 10:48:36

How to display items by specific activity date?

There is an infoblock with several elements with a specific date of activity. It is required to display infoblocks with the date of activity, say, only 07/20/2019. Using the filter as a whole solves the problem, but if you set the date 07/19/2019, then active infoblocks will be displayed on the 19th and 20th. $filter = array("=ACTIVE_FROM" => "20.07.2019");

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
serginhold, 2019-07-23
@DeboshiR

It would not be fate to see what sql query is generated and think a little?
Active_from is the start of the activity. It is logical that if you do not limit on the other hand, then everything after the specified date will be displayed.
In short, you take the 19th number, this is >= active_from. You add a day to the previous date, you get the 20th number, this is <active_to. That's it, these are your two filter values.
Ps since the strange Bitrix requires a date in a strange format, which is associated with some site settings, I advise you to pass values ​​\u200b\u200bto the filter using Bitrix\Main\Type\DateTime, it will format everything itself

I
Israpil Akhmedov, 2019-07-23
@xISRAPILx

$filter = array("=ACTIVE_FROM" => "07/19/2019", "=ACTIVE_TO" => "07/19/2019");
You can also try
$filter = array("=ACTIVE" => "07/19/2019")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question