# Auto Fill Dates

A tutorial showing how auto filling dates works in SpreadJS

## Content

SpreadJS allows users to automatically fill dates in the worksheet by using the drag fill option.
You can simply drag the fill handle in an upward or downward direction to fill days, weekdays, months, and years across the entire column in the worksheet. Also, you can quickly carry out other custom date filling operations like filling the first day of the month, filling the same day of the month, filling the last day of the month, etc. as shown in the example shared below.
![SpreadJS worksheet date drag fill workflow showing the fill handle used to populate a column with date series such as days, months, or years.](https://cdn.mescius.io/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/images/date-dragfill.gif)

## Using Code

```javascript
const sheet = spread.getActiveSheet();

// Fill the first day of each month.
sheet.setValue(0, 0, new Date(2018, 4, 1));
sheet.setValue(1, 0, new Date(2018, 5, 1));
sheet.getRange(0, 0, 6, 1).formatter("m/d/yyyy");

sheet.fillAuto(
    new GC.Spread.Sheets.Range(0, 0, 2, 1),
    new GC.Spread.Sheets.Range(0, 0, 6, 1),
    {
        fillType: GC.Spread.Sheets.Fill.FillType.date,
        series: GC.Spread.Sheets.Fill.FillSeries.column,
        fillDirection: GC.Spread.Sheets.Fill.FillDirection.down,
        unit: GC.Spread.Sheets.Fill.FillDateUnit.month,
        step: 1        
    }
);

// Result:
// 5/1/2018
// 6/1/2018
// 7/1/2018
// 8/1/2018
// 9/1/2018
// 10/1/2018
```