Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

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

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'.


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


firstname and lastname works fine.

Any help?


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 }}"; 
If you find this post helpful consider marking it as a solution to help others find it.

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: 






Also, I used like below:


var birthdate="{{ user.birthdate }}"; 


and got below in alert:​





New Member

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

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!

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

Helpful resources

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (2,182)