Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Unanswered

Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

(0) ShareShare
ReportReport
Posted on by 11

I'm trying to get birthDate (and other date fields) of the portal user(contact) in liquid in a content snippet, it give me the error "Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

<script>

var firstname="{{ user.firstname }}";
var lastname="{{ user.lastname }}";
var birthdate="{{ user.birthdate | string }}"; //"{{ user.birthdate }}";
</script>

 

firstname and lastname works fine.

Any help?

  • Eduardo_Garcia Profile Picture
    5 on at
    Re: Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

    Thanks, but it doesn't work. It seems like the latest portal update broke parsing of boolean and datetime for the user object.

  • H V Profile Picture
    1,510 on at
    Re: Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

    Hi @siddiqueMahsud  & @Eduardo_Garcia 

     

    Can you please try below code:

    {% assign birthDate = user.birthdate %}
    {{ birthDate }}

     

    --------------------------
    If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

  • Eduardo_Garcia Profile Picture
    5 on at
    Re: Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

    I'm getting the same issue out of nowhere. Any ideas?

  • Siddique mahsud Profile Picture
    11 on at
    Re: Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

    thank you OOlashyn for your response, seems like there is some issue with my portal, as I'm used the same as you mentioned but not working.

    I just simply need the birthdate, no matter what is the format.

    My sample code: 

    siddiqueMahsud_7-1631255072873.png

     


    Output:

    siddiqueMahsud_6-1631255059524.png

     


    Also, I used like below:

     

    var birthdate="{{ user.birthdate }}"; 
    alert(birthdate);

     

    and got below in alert:​

    siddiqueMahsud_3-1631254681115.png

     

     

     

  • OOlashyn Profile Picture
    3,496 Most Valuable Professional on at
    Re: Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

    Hi @siddiqueMahsud,

    If you would like to convert datetime to a specific format check this official doc regarding available datetime filters.

    var date = "{{ now | date: 'MMM dd, yyyy' }}";
    // output Sep 09, 2021

    If you just want to print that value to use as a string you don't need any additional filter and this code will work just fine:

    // this will be a string
    var birthdate="{{ user.birthdate }}"; 

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35