DATEDIFFでエントリを注文する
Oct 27 2020
2つの日付フィールドの違いでエントリクエリの結果を並べ替えようとしていますが、機能しないようです。
これが私の質問です:
{% set todaysStreamsParams = {
section : 'films',
orderBy : "DATEDIFF(`screeningDateFirst`, `screeningDateLast`) DESC",
limit : 5,
} %}
{% set todaysStreams = craft.entries(todaysStreamsParams).all() %}
しかし、次のデータベース例外が発生します。
Unknown column 'screeningDateFirst' in 'order clause.
任意のヒント?
回答
1 DocumentServices Oct 27 2020 at 08:43
少し掘り下げてみると、より複雑な注文クエリを完全に詳しく説明する必要があるようです。私はそれが機能するように次のように調整しました:
orderBy : "DATEDIFF(`content`.`field_screeningDateFirst`, `content`.`field_screeningDateLast`) DESC",