# Set a date based on a Quarter and Year

> Here is how you can use the Custom JavaScript pipe › Moment.js call to set a date field based on what Quarter and Year are set and use that to update a…

Source: https://tadabase.com/docs/snippets/set-a-date-based-on-a-quarter-and-year  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

![Screenshot for “Set a date based on a Quarter and Year”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-17_23-43-19.png)

Here is how you can use the Custom JavaScript pipe > Moment.js call to set a date field based on what Quarter and Year are set and use that to update a Status field.

**Step 1**

**Install the Custom JavaScript pipe. Within the API Calls of the pipe, set up the parameters as shown in the image below.**

![Screenshot for “Set a date based on a Quarter and Year”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-17_23-47-39.png)

**Step 2**

**Within the Request tab of the API calls, add the following code.**

```
var outputDate;
if ('{quarter}' === 'Q1') {
    outputDate = moment('{year}-03-31').format('L');
} else if ('{quarter}' === 'Q2') {
    outputDate = moment('{year}-06-30').format('L');
} else if ('{quarter}' === 'Q3') {
    outputDate = moment('{year}-09-30').format('L');
} else {
    outputDate = moment('{year}-12-31').format('L');
}

outputDate
```

![Screenshot for “Set a date based on a Quarter and Year”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-17_23-47-59.png)

**Step 3**

**Set the following table rules when a record is "created or edited."**

**#1**

![Screenshot for “Set a date based on a Quarter and Year”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-18_01-30-32.png)

**#2**

![Screenshot for “Set a date based on a Quarter and Year”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-18_01-33-28.png)

**#3**

![Screenshot for “Set a date based on a Quarter and Year”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-18_01-34-38.png)

**Original Community Post:**

[Set a date based on a Quarter and Year - Community Discussions / Pipes - Tadabase Community](https://community.tadabase.io/t/set-a-date-based-on-a-quarter-and-year/1590)
