Assuming your date is in column A and your time in column B try:
=IF(WEEKDAY(A2,2)>5,TEXT(WORKDAY(A2,1),"dd/mm/yyyy"),TEXT(IF(HOUR(B2)>18,WORKDAY(A2,1),A2),"dd/mm/yyyy"))&IF(AND(HOUR(B2)>=6,HOUR(B2)<=18)," @ "&IF(HOUR(B2)>12,HOUR(B2)-12,HOUR(B2))&" PM"," @ 6 AM")
There's 2 parts to the formula, one that looks at the date to see if it's a weekday and also looks at whether it's after 6 PM. - IF(WEEKDAY(A2,2)>5,TEXT(WORKDAY(A2,1),"dd/mm/yyyy"),TEXT(IF(HOUR(B2)>18,WORKDAY(A2,1),A2),"dd/mm/yyyy"))
The second looks at times to return either @6 AM or the actual hour between 6 AM and 6 PM. - IF(AND(HOUR(B2)>=6,HOUR(B2)<=18)," @ "&IF(HOUR(B2)>12,HOUR(B2)-12,HOUR(B2))&" PM"," @ 6 AM")
if you have both date and time in only 1 cell, you can get the time in a separate cell with
=TIME(HOUR(A2),MINUTE(A2),SECOND(A2))
If you're working with the American date format, change WEEKDAY(A2,2) to WEEKDAY(A2,1) and change "dd/mm/yyyy" (there are 2 instances in the formula) to "mm/dd/yyyy" or whatever format you want. There might be other tweaks to get this in american format but I only work with the European format and can't be bothered to change it.
Bookmarks