In this Article, we are going to discuss how to print the latest orders saved in a table, using the liquid script.

To be able to do so, we need to make sure that our table has a “DateTime” column in which the order “DateTime” are saved. This ”DateTime” column will be used to compare the order “DateTime“ with the current “DateTime” and print the latest orders.

Let us assume we have a table named “abc” that has a column “order_dt” which contains the order dates and time. Now, using the liquid script we will compare the “order_dt” with the current “DateTime” and print only the orders which are the latest (latest within an hour's range). As we know that the default” DateTime” format in Maropost is YYYY-MM-DD HH:MM:SS, the “DateTime” values would be saved in an identical format. Comparing the exact” DateTime with the now “dateTime” won’t be possible since we need a time window to be able to send the campaign, so that the liquid is parsed correctly.

( Note: “NowTime" refers to the current time fetched through the liquid tag {{now | date: "Y-%m-%d %H"}} | The "NowTime" fetches current date and time based on the EST current time)

(Refer to this link to know more on how to use the "Now" liquid tag -

So, according to the information above, we only need to compare the Date and the Hours of our Order DateTime with the Date and Hours of the “NowTime”. For example, if we have an order with the Order DateTime as 2018-01-25 13:00:15, we are only going to fetch the Year, Month, Date and the Hours out of the DateTime value and compare them with the Year, Month, Date & Hours of the “NowTime”.

The reason only the Year, Month, Date & Hours are being compared with the “NowTime” is because it is going to take some time to schedule and send a campaign. For example, if the order was placed at 2018-01-25 13:00:15, the minutes and hours would have already elapsed when the contact receives the campaign, therefore, the Liquid Script won’t print anything. So, taking the above example and similar scenarios in consideration, we will only compare the Year, Month, Date and Hours of the Order with the “NowTime”.

Applying this approach, the system will pick only those orders whose date and hour values match the Year, Month, Date and Hour values of the “NowTime”.

Table structure in the example:

Table Name - abc

Column containing order details - order_dt

Column containing product name - product

Lets look at the liquid script:

{% for item in table.abc_all %}

{% assign order_date = item.order_dt | date: "%Y-%m-%d %H" %}

{% assign today_date = "now" | date: "%Y-%m-%d %H" %}

{% if order_date == today_date %}


{% endif %}

{% endfor %}


  • In the first step, we are fetching all the columns present in the table abc (using FOR loop.To know more about “For loops”, use this link -
  • Next, we will assign the variable “order_date” to the values present in the column “order_dt” contained in the table abc. We are only assigning the year, month, date and hour information from the format YYYY-MM-DD HH:MM:SS to the variable.
  • We will assign the ‘Now’ “DateTime” to a variable “today_date”. ‘Now’ is a default feature of the Liquid to fetch the current date and time.
  • All that remains to be done is to compare the date and time of the data present in the table column “order_dt” with the now “DateTime”.
  • Finally, the option{{item.product}}would help to print the item, from the table, that you wish to be displayed in the email.
  • Hope this article provided ample insight and is helpful in determining how the “Liquid” can be used to fetch and compare details with the current time.

 The code can be modified according to your preferences.