4

I'm trying to repeat something like this for every day of the year. It could start at anytime, for example, like below:

01/01/2020 06:00:00
01/01/2020 07:00:00
.... .... ... Then...
01/01/2020 20:00:00
02/01/2020 06:00:00
02/01/2020 07:00:00
.... .... ... Then...
02/01/2020 20:00:00
03/01/2020 06:00:00
03/01/2020 07:00:00

I tried the following link, but this only worked on texts. Repeat a range a number of times

Another one I've tried is this, but I cannot set the start/end time: Repeat date sequence in Excel

Any help would be greatly appreciated!

Mayukh Bhattacharya
  • 12,541
  • 5
  • 21
  • 32
Sophia
  • 41
  • 3

3 Answers3

4

If you got Excel 365 use @SpencerBarnes with no doubt, but in case you got and older version of Excel you may do:

A1 = 01/01/2020 06:00:00

A2 = =IF(HOUR(A1)=20;INT(A1)+1+1/4;A1+1/24)

The main disavantadge of this solution is that you need manually to drag until last day of year... so if you can use @SpencerBarnes use it.

3

The below formula takes a SEQUENCE of every single hour, then filters it down to only the time ranges you need (in this case between TIME(6,0,0) and TIME(20,0,0), so 6:00 to 20:00).

=LET(
AllHours, SEQUENCE(365*24, 1, DATE(2022, 1, 1), TIME(1,0,0)),
IsCorrectTime, BYROW(AllHours,LAMBDA(row,AND(MOD(row, 1)>=TIME(6,0,0),MOD(row,1)<=TIME(20,0,0)))),
FILTER(AllHours, IsCorrectTime)
)
Spencer Barnes
  • 2,809
  • 1
  • 7
  • 26
1

Repeat/Increment Date Time In Column

=LET(Data,A2:A4,Repeats,C1,Start,C2,
    rs,ROWS(Data),s,Start-1,Seq,SEQUENCE(rs*Repeats-s,,s),
INDEX(Data,MOD(Seq,rs)+1)+INT(Seq/rs))

enter image description here

VBasic2008
  • 44,888
  • 5
  • 17
  • 28