I am trying to use VLookup
or QUERY
to extract a day and time description based on the current date and time. I thought QUERY
may be the b
If you have =NOW() in A2, this formula should work without any additional tabs or descriptions...
Apologies, i'd originally Missed the necessity of the day of the week as well. This should work. Again, just with NOW() in A2 and nothing else on the sheet.
=ARRAYFORMULA(JOIN(" ",VLOOKUP(MOD(A2,{7,1}),SORT({{{7;9;16;20}/24;SEQUENCE(7,1,0)},{"Breakfast";"Morning";"Daytime";"Evening";TEXT(SEQUENCE(7,1,0),"ffffdd")}}),2)))
based on your time data logic try:
=ARRAYFORMULA(IFERROR(TEXT(A2:A, "ffffdd ")&VLOOKUP(TIMEVALUE(A2:A), {
TIMEVALUE("00:00"), "Evening";
TIMEVALUE("07:00"), "Breakfast";
TIMEVALUE("09:00"), "Morning";
TIMEVALUE("16:00"), "Daytime";
TIMEVALUE("20:00"), "Evening"}, 2, 1)))
for non-hardcoded references use:
=ARRAYFORMULA(IFERROR(TEXT(A2:A, "ffffdd ")&VLOOKUP(TIMEVALUE(A2:A),
SORT({TIMEVALUE(REGEXEXTRACT(TimeDescription!A2:A, "(.*) -")),
TimeDescription!B2:B}, 1, 1), 2, 1)))