Replace a Date/Time field which store Date & time, with a Date Only field and a choice field + 5 cal
I use to have a sharepoint column of type Date/Time which allow Date & Time, but when i am viewing this field inside PnP Modern search web part, i will get the date & time in UTC and not in local sharepoint site time zone (which is pacific time US & Canada). i tried to format the data using this library , but still there will be 2 hours differences:-
{{ getDate (getDate (slot item @root.slots.PUETA) “YYYY-MM-DDTHH:mm:ss.0000000Z”) “MMMM DD, YYYY h:mm a” 3 }}
so i decided to take this appraoch instead, where instead of having single column of type Date/Time, i created 2 columns:-
Date only field..named “PUETADate”choice field with values such as 12:00 AM, 2;00 PM, and so one.. named “PUETATime”
then to be able to sort and filter the combination of those fields, i created 5 calculated columns:-
PUETAAMHour
=IF(AND(ISERROR(FIND(“PM”,PUETATime)),ISERROR(FIND(“:30″,PUETATime))),IF(PUETATime=”12:00 AM”,PUETADate,IF(PUETATime=”1:00 AM”,PUETADate+60/(2460),IF(PUETATime=”2:00 AM”,PUETADate+120/(2460),IF(PUETATime=”3:00 AM”,PUETADate+180/(2460),IF(PUETATime=”4:00 AM”,PUETADate+240/(2460),IF(PUETATime=”5:00 AM”,PUETADate+300/(2460),IF(PUETATime=”6:00 AM”,PUETADate+360/(2460),IF(PUETATime=”7:00 AM”,PUETADate+420/(2460),IF(PUETATime=”8:00 AM”,PUETADate+480/(2460),IF(PUETATime=”9:00 AM”,PUETADate+540/(2460),IF(PUETATime=”10:00 AM”,PUETADate+600/(2460),IF(PUETATime=”11:00 AM”,PUETADate+660/(24*60))))))))))))))
PUETAAMHalfHour
=IF(AND(ISERROR(FIND(“PM”,PUETATime)),ISERROR(FIND(“:00″,PUETATime))),IF(PUETATime=”12:30 AM”,PUETADate+30/(2460),IF(PUETATime=”1:30 AM”,PUETADate+90/(2460),IF(PUETATime=”2:30 AM”,PUETADate+150/(2460),IF(PUETATime=”3:30 AM”,PUETADate+210/(2460),IF(PUETATime=”4:30 AM”,PUETADate+270/(2460),IF(PUETATime=”5:30 AM”,PUETADate+330/(2460),IF(PUETATime=”6:30 AM”,PUETADate+390/(2460),IF(PUETATime=”7:30 AM”,PUETADate+450/(2460),IF(PUETATime=”8:30 AM”,PUETADate+510/(2460),IF(PUETATime=”9:30 AM”,PUETADate+570/(2460),IF(PUETATime=”10:30 AM”,PUETADate+630/(2460),IF(PUETATime=”11:30 AM”,PUETADate+690/(2460))))))))))))))
PUETAPMHour
=IF(AND(ISERROR(FIND(“AM”,PUETATime)),ISERROR(FIND(“:30″,PUETATime))),IF(PUETATime=”12:00 PM”,PUETADate+720/(2460),IF(PUETATime=”1:00 PM”,PUETADate+780/(2460),IF(PUETATime=”2:00 PM”,PUETADate+840/(2460),IF(PUETATime=”3:00 PM”,PUETADate+900/(2460),IF(PUETATime=”4:00 PM”,PUETADate+960/(2460),IF(PUETATime=”5:00 PM”,PUETADate+1020/(2460),IF(PUETATime=”6:00 PM”,PUETADate+1080/(2460),IF(PUETATime=”7:00 PM”,PUETADate+1140/(2460),IF(PUETATime=”8:00 PM”,PUETADate+1200/(2460),IF(PUETATime=”9:00 PM”,PUETADate+1260/(2460),IF(PUETATime=”10:00 PM”,PUETADate+1320/(2460),IF(PUETATime=”11:00 PM”,PUETADate+1380/(2460))))))))))))))
PUETAPMHalfHour
=IF(AND(ISERROR(FIND(“AM”,PUETATime)),ISERROR(FIND(“:00″,PUETATime))),IF(PUETATime=”12:30 PM”,PUETADate+750/(2460),IF(PUETATime=”1:30 PM”,PUETADate+810/(2460),IF(PUETATime=”2:30 PM”,PUETADate+870/(2460),IF(PUETATime=”3:30 PM”,PUETADate+930/(2460),IF(PUETATime=”4:30 PM”,PUETADate+990/(2460),IF(PUETATime=”5:30 PM”,PUETADate+1050/(2460),IF(PUETATime=”6:30 PM”,PUETADate+1110/(2460),IF(PUETATime=”7:30 PM”,PUETADate+1170/(2460),IF(PUETATime=”8:30 PM”,PUETADate+1230/(2460),IF(PUETATime=”9:30 PM”,PUETADate+1290/(2460),IF(PUETATime=”10:30 PM”,PUETADate+1350/(2460),IF(PUETATime=”11:30 PM”,PUETADate+1410/(2460))))))))))))))
then the final date/time as calculated column named “PUETADateTime” with this formula:-
=PUETAAMHalfHour+PUETAAMHour+PUETAPMHalfHour+PUETAPMHour
i know this sound too much, but at-least when i show the managed property which is linked to the PUETADateTime” column, i will get precise value unlike having a single Date/Time field which will show the Date/Time in UTC.. is my above approach value?
Hint, i have to create the first 4 calculated columns, instead of one calculated column, since in sharepoint online we can only have max of 19 nested IF inside single calculated column formula.
Thanks
I use to have a sharepoint column of type Date/Time which allow Date & Time, but when i am viewing this field inside PnP Modern search web part, i will get the date & time in UTC and not in local sharepoint site time zone (which is pacific time US & Canada). i tried to format the data using this library , but still there will be 2 hours differences:- {{ getDate (getDate (slot item @root.slots.PUETA) “YYYY-MM-DDTHH:mm:ss.0000000Z”) “MMMM DD, YYYY h:mm a” 3 }}so i decided to take this appraoch instead, where instead of having single column of type Date/Time, i created 2 columns:-Date only field..named “PUETADate”choice field with values such as 12:00 AM, 2;00 PM, and so one.. named “PUETATime”then to be able to sort and filter the combination of those fields, i created 5 calculated columns:-PUETAAMHour=IF(AND(ISERROR(FIND(“PM”,PUETATime)),ISERROR(FIND(“:30″,PUETATime))),IF(PUETATime=”12:00 AM”,PUETADate,IF(PUETATime=”1:00 AM”,PUETADate+60/(2460),IF(PUETATime=”2:00 AM”,PUETADate+120/(2460),IF(PUETATime=”3:00 AM”,PUETADate+180/(2460),IF(PUETATime=”4:00 AM”,PUETADate+240/(2460),IF(PUETATime=”5:00 AM”,PUETADate+300/(2460),IF(PUETATime=”6:00 AM”,PUETADate+360/(2460),IF(PUETATime=”7:00 AM”,PUETADate+420/(2460),IF(PUETATime=”8:00 AM”,PUETADate+480/(2460),IF(PUETATime=”9:00 AM”,PUETADate+540/(2460),IF(PUETATime=”10:00 AM”,PUETADate+600/(2460),IF(PUETATime=”11:00 AM”,PUETADate+660/(24*60))))))))))))))PUETAAMHalfHour=IF(AND(ISERROR(FIND(“PM”,PUETATime)),ISERROR(FIND(“:00″,PUETATime))),IF(PUETATime=”12:30 AM”,PUETADate+30/(2460),IF(PUETATime=”1:30 AM”,PUETADate+90/(2460),IF(PUETATime=”2:30 AM”,PUETADate+150/(2460),IF(PUETATime=”3:30 AM”,PUETADate+210/(2460),IF(PUETATime=”4:30 AM”,PUETADate+270/(2460),IF(PUETATime=”5:30 AM”,PUETADate+330/(2460),IF(PUETATime=”6:30 AM”,PUETADate+390/(2460),IF(PUETATime=”7:30 AM”,PUETADate+450/(2460),IF(PUETATime=”8:30 AM”,PUETADate+510/(2460),IF(PUETATime=”9:30 AM”,PUETADate+570/(2460),IF(PUETATime=”10:30 AM”,PUETADate+630/(2460),IF(PUETATime=”11:30 AM”,PUETADate+690/(2460))))))))))))))PUETAPMHour=IF(AND(ISERROR(FIND(“AM”,PUETATime)),ISERROR(FIND(“:30″,PUETATime))),IF(PUETATime=”12:00 PM”,PUETADate+720/(2460),IF(PUETATime=”1:00 PM”,PUETADate+780/(2460),IF(PUETATime=”2:00 PM”,PUETADate+840/(2460),IF(PUETATime=”3:00 PM”,PUETADate+900/(2460),IF(PUETATime=”4:00 PM”,PUETADate+960/(2460),IF(PUETATime=”5:00 PM”,PUETADate+1020/(2460),IF(PUETATime=”6:00 PM”,PUETADate+1080/(2460),IF(PUETATime=”7:00 PM”,PUETADate+1140/(2460),IF(PUETATime=”8:00 PM”,PUETADate+1200/(2460),IF(PUETATime=”9:00 PM”,PUETADate+1260/(2460),IF(PUETATime=”10:00 PM”,PUETADate+1320/(2460),IF(PUETATime=”11:00 PM”,PUETADate+1380/(2460))))))))))))))PUETAPMHalfHour=IF(AND(ISERROR(FIND(“AM”,PUETATime)),ISERROR(FIND(“:00″,PUETATime))),IF(PUETATime=”12:30 PM”,PUETADate+750/(2460),IF(PUETATime=”1:30 PM”,PUETADate+810/(2460),IF(PUETATime=”2:30 PM”,PUETADate+870/(2460),IF(PUETATime=”3:30 PM”,PUETADate+930/(2460),IF(PUETATime=”4:30 PM”,PUETADate+990/(2460),IF(PUETATime=”5:30 PM”,PUETADate+1050/(2460),IF(PUETATime=”6:30 PM”,PUETADate+1110/(2460),IF(PUETATime=”7:30 PM”,PUETADate+1170/(2460),IF(PUETATime=”8:30 PM”,PUETADate+1230/(2460),IF(PUETATime=”9:30 PM”,PUETADate+1290/(2460),IF(PUETATime=”10:30 PM”,PUETADate+1350/(2460),IF(PUETATime=”11:30 PM”,PUETADate+1410/(2460)))))))))))))) then the final date/time as calculated column named “PUETADateTime” with this formula:- =PUETAAMHalfHour+PUETAAMHour+PUETAPMHalfHour+PUETAPMHour i know this sound too much, but at-least when i show the managed property which is linked to the PUETADateTime” column, i will get precise value unlike having a single Date/Time field which will show the Date/Time in UTC.. is my above approach value?Hint, i have to create the first 4 calculated columns, instead of one calculated column, since in sharepoint online we can only have max of 19 nested IF inside single calculated column formula.Thanks Read More