Home > Back-end >  How to generate sequences in Google Sheets
How to generate sequences in Google Sheets

Time:09-07

I'l like to create a sequence of dates using "sequence formula" with a start and end date. I mean, something like this:

start date = 2020-01-01
end date = 2022-12-01

I just also want to bring the first day of the month, like the following example:

2020-01-01
2020-02-01
2020-03-01
......
2022-10-01
2022-11-01
2022-12-01

How can I get this? Is there another way to do it?

Thanks!!!

CodePudding user response:

  1. Write =SEQUENCE( in an empty cell, to start the formula.
  2. Write the row and column arguments divided by a comma. In our example, we are using 10 for the row argument and 1 for column.
  3. Now we need to write the start argument here. Instead, we start writing the date formula. In this case, we write DATE(2022,1,1).
  4. Add another comma and input the step argument. In this case, it is 1 to have single sequential days. If you wanted to do weeks, you could type 7 instead.
  5. Finally, add the closing bracket and press Enter.

OUTPUT

enter image description here

CodePudding user response:

There are several ways to approach this. Here is one I recommend:

=ArrayFormula(DATE(2020,SEQUENCE(DATEDIF("2020-01-01", "2022-12-01", "m") 1),1))

You'll replace the first 2020 with the year of your starting date and the next two string-dates with your full start and end date. That's it.

Just make sure you leave enough cells open below this formula to accommodate the number of dates you're requiring the formula to output.

Format the output range in the date format you prefer (Format > Number...).

  • Related