Forum Discussion
JamesMWood
Jul 06, 2020Copper Contributor
SharePoint Online Date calculation with JSON
is there a way to calculate a date value in a column based upon the entered date in one column plus a duration entered in another column, e.g. I am recording a purchase date on an item and its warran...
- Jul 06, 2020
Hi JamesMWood you can do this with a simple flow in Power Automate. The columns are StartDate (DateTime), WarrantyYears(Number) and WarrantyExpiryDate (DateTime). When an item is created or modified in your SharePoint list we calculate the number of warranty days (years x 365), convert that to an integer and then add those days to the start date. Finally we update the SharePoint item with the warranty expiry date:
I always like to split up my Compose controls so that it's easy to see what each one is doing, but you could combine them if you wished to. The expressions in each Compose are shown in the comments.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
RobElliott
Jul 06, 2020Silver Contributor
Hi JamesMWood you can do this with a simple flow in Power Automate. The columns are StartDate (DateTime), WarrantyYears(Number) and WarrantyExpiryDate (DateTime). When an item is created or modified in your SharePoint list we calculate the number of warranty days (years x 365), convert that to an integer and then add those days to the start date. Finally we update the SharePoint item with the warranty expiry date:
I always like to split up my Compose controls so that it's easy to see what each one is doing, but you could combine them if you wished to. The expressions in each Compose are shown in the comments.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
JamesMWood
Jul 08, 2020Copper Contributor
RobElliott Hi Rob, I have used the Compose options that you provided and when I updated the entry to test the flow I got the following error:
InvalidTemplate. Unable to process template language expressions in action 'ComposeWarrantyDays' inputs at line '1' and column '14067': 'The template language function 'mul' expects its first parameter to be an integer or a decimal number. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#mul for usage details.'.
- RobElliottJul 08, 2020Silver Contributor
JamesMWood that indicates you've got no value in the Warranty period for one of the items in your list.
Rob
Los Gallardos
Microsoft Power Automate Community Super User- JamesMWoodJul 08, 2020Copper ContributorHi Rob that was what I able to decipher but when I checked the list all items have a value for the warranty period, I've looked at the column formatting as well and I cannot see any issues