# How to write date period calculation in QS?

**URL:** <https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757>\
**Category:** Q&A\
**Tags:** feature-request, developer, quick-sight\
**Created:** [September 18, 2025, 3:24pm UTC](https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757 "2025-09-18T15:24:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cnagabhairava](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Cnagabhairava](https://community.amazonquick.com/u/Cnagabhairava)\
**Post date:** [September 18, 2025, 3:24pm UTC](https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757/1 "2025-09-18T15:24:56Z")

</div>

Hi team could you please help me to write date period clac using parameter

if date param=’year’ then year(today)

else if date param=’ previous year’ then datetrunc(‘year’,today())-1

elseif date param=’quarter’ then datetrunc(‘quarter’,today())

elseif date param=’previous quarter’ then datetrunc(‘quarter’, dateadd(‘day’,-1,datetrunc(‘quartrer’,today()))

elseif ‘none’

above calc is working in QS? if not please help me to write correct calc.

Thanks in advanced

Regards,

Chaitanyakumar N

---

<div class="post-metadata">

**Author:** ![SaiChema](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@SaiChema](https://community.amazonquick.com/u/SaiChema)\
**Post date:** [September 18, 2025, 3:30pm UTC](https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757/2 "2025-09-18T15:30:02Z")

</div>

> [@Cnagabhairava](#):
>
> Hi team could you please help me to write date period clac using parameter
> 
> if date param=’year’ then year(today)
> 
> else if date param=’ previous year’ then datetrunc(‘year’,today())-1
> 
> elseif date param=’quarter’ then datetrunc(‘quarter’,today())
> 
> elseif date param=’previous quarter’ then datetrunc(‘quarter’, dateadd(‘day’,-1,datetrunc(‘quartrer’,today()))
> 
> elseif ‘none’
> 
> above calc is working in QS? if not please help me to write correct calc.

Consider using the now() function in Quick Sight [Now - Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/now-function.html)

You can use a combination of other date functions [Functions by category - Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/functions-by-category.html#date-functions) to extract the day/month/year value from now’s value.

---

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [September 28, 2025, 7:15am UTC](https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757/3 "2025-09-28T07:15:33Z")

</div>

Hi @Cnagabhairava

It’s been a while since we last heard from you. If you have any further questions, please let us know how we can assist you.

If we don’t hear back within the next 3 business days, we’ll proceed with close/archive this topic.

Thank you!

---

<div class="post-metadata">

**Author:** ![Cnagabhairava](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Cnagabhairava](https://community.amazonquick.com/u/Cnagabhairava)\
**Post date:** [September 29, 2025, 6:55am UTC](https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757/4 "2025-09-29T06:55:38Z")

</div>

yes please Xclipse, I need solution for my question

---

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [October 11, 2025, 6:53am UTC](https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757/5 "2025-10-11T06:53:49Z")

</div>

Hi @Cnagabhairava

You can use the [now()](https://docs.aws.amazon.com/quicksuite/latest/userguide/now-function.html), [addDateTime()](https://docs.aws.amazon.com/quicksuite/latest/userguide/addDateTime-function.html), and [extract()](https://docs.aws.amazon.com/quicksuite/latest/userguide/extract-function.html) functions to extract the Year, Quarter, and Previous Year and Quarter.

**Example:**

```auto
Year - extract('YYYY', now())

Previous Year - extract('YYYY',addDateTime(-1, 'YYYY', now()))

Quarter - extract('Q', now())

Previous Quarter - extract('Q',addDateTime(-1, 'Q', now()))

```

---

<div class="post-metadata">

**Author:** ![Cnagabhairava](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Cnagabhairava](https://community.amazonquick.com/u/Cnagabhairava)\
**Post date:** [October 12, 2025, 8:34am UTC](https://community.amazonquick.com/t/how-to-write-date-period-calculation-in-qs/49757/6 "2025-10-12T08:34:06Z")

</div>

Thank you for answering and support
