web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Calculate the differen...
Power Pages
Answered

Calculate the difference between two dates using liquid

(0) ShareShare
ReportReport
Posted on by 31

Would anyone know how to get the difference in days between two dates using liquid? I can't figure it out. 

 

{% assign date1 = "12/10/2020 12:00:00 AM" %}

{% assign date2 = "13/10/2020 12:00:00 AM" %}

the output should be 1 - for 1 day between 

 

I have researched a lot and found "date: '%s'" works for normal liquid - but in PowerApps liquid the '%s' represents the seconds.

 

{% assign date2 = "13/10/2020 12:00:00 AM" | date: '%s' %}

 

Cheers in advance!

Categories:
I have the same question (0)
  • Verified answer
    Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    (I am assuming your %s was attempting to get seconds from epoch so you could subtract numbers)

     

    For date objects 'minus' works

     

     

    Try this Liquid to see the date subtract
    
    {% assign date1 = now %} 
    {% assign date2 = date1 | date_add_days: -5 %} 
    Date1: {{ date1 }}<br />
    Date2: {{ date2 }}<br />
    Subtracted: {{ date1 | minus: date2 }}<br />

     

     

    You'll notice the output is days:minutes:seconds (so depending on what you need to do you may need to extract what you need and further manipulate it.

     

    For the above I 'stole' ideas from a post in this thread:  https://stackoverflow.com/questions/42429448/get-date-difference-using-adx-studio-liquid-template

     

     

    {% if item.dob %}
    {% assign words = now | minus: item.dob | string | split: '.' %} 
    {% assign days = words.first | integer %} 
    {{ days | divided_by: 365 }}
    {% endif %}

     

     

    Depending on what you are actually doing, do you need this in Liquid e.g. if it is something on the page you may be able to use Liquid to write JavaScript variables and then do the work in JavaScript. 

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 21 Super User 2026 Season 1

#2
Fubar Profile Picture

Fubar 19 Super User 2026 Season 1

#3
CN-06091549-0 Profile Picture

CN-06091549-0 18

Last 30 days Overall leaderboard