Help with date in Json

New Contributor

Hi all,

Im fairly new to Sharepoint and I'm learning about JSON formatting but i have a situation that has me a bit confused, hopefully you can help me clarify.

 

I have a list of outsource personnel. In that list i have 3 columns. "Name", "Start Date", and "End Date". (Name is a text field and start and end dates are date fields).

 

I have second "Lab" list where I'm trying some stuff and I've created one lookup column named "_Name" where im grabbing the name of the my outsource personnel list and I'm also showing the two dates columns now under _Name:Start Date and _Name:End Date.

 

I also created (on the lab list) another date type column named "test" and i just want to display the content of the lookup "_Name:Start Date" column as a date (im just practicing some stuff btw)

So basically this is what i have

 

 

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "=Date([$_Name_x003a_Start_Date.lookupValue])"
}

 

Under test i see a date, BUT its showing the date of 12/31/1969 19:00:00 instead of the date i have populated 06/21/2021 17:00:00.

As far as i know im just converting the value from _Name:Start Date into a date format, but i dont know why am i getting a different date.

Any clues about what could the be problem?

thanks in advance
Juan

1 Reply

@Jsanjur

You cannot use the extended columns in lookup in JSON formatting. You can only use the lookupId & lookupValue (Main value - Name).

 

From documentation

The lookup field object has the following properties (with example values):

 

{
   "lookupId": "100",
   "lookupValue": "North America",
}

 

You can only use the value of column you selected in lookup settings - In this column:

ganeshsanap_0-1623576601346.png


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.