Select “Time Description” based on current date and time in Google Sheets (VLookup, Query)

前端 未结 2 1280
走了就别回头了
走了就别回头了 2021-01-22 16:38

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

相关标签:
2条回答
  • 2021-01-22 17:02

    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)))
    
    0 讨论(0)
  • 2021-01-22 17:26

    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)))
    

    spreadsheet demo

    0 讨论(0)
提交回复
热议问题