# Calculate Expiration Dates Using DQL for Accurate Tracking

**URL:** <https://community.dynatrace.com/t/calculate-expiration-dates-using-dql-for-accurate-tracking/54094>\
**Category:** DQL\
**Tags:** real-user-monitoring-classic, dql\
**Created:** [November 14, 2025, 9:06pm UTC](https://community.dynatrace.com/t/calculate-expiration-dates-using-dql-for-accurate-tracking/54094 "2025-11-14T21:06:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![orchidee](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@orchidee](https://community.dynatrace.com/u/orchidee)\
**Post date:** [November 14, 2025, 9:06pm UTC](https://community.dynatrace.com/t/calculate-expiration-dates-using-dql-for-accurate-tracking/54094/1 "2025-11-14T21:06:50Z")

</div>

I want to have a DQL query to calculate expiry date for a creation date to be expired in 90 days. However, the date value is raw, e.g. 2025-02-10T20:45:00.000+0000.

I tried using a simple calculation like&nbsp;TokenExpiryDate = CreatedDate + duration(90, “d”) but displays as null. If I use timestamp, e.g. timestampy(CreatedDate), it gives me error. Can someone please share what else is missing? Tried asking copilot but not too helpful.

---

<div class="post-metadata">

**Author:** ![t\_pawlak](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/t_pawlak/32/14991_2.png) [@t\_pawlak](https://community.dynatrace.com/u/t_pawlak)\
**Post date:** [November 17, 2025, 10:25am UTC](https://community.dynatrace.com/t/calculate-expiration-dates-using-dql-for-accurate-tracking/54094/2 "2025-11-17T10:25:19Z")

</div>

Hi,  
In DQL you can’t use a field that you just created in the same fieldsAdd.  
Your DQL

will give: The field CreatedTs doesn’t exist, because TokenExpiryDate can’t “see” CreatedTs yet.  
Try this way:

```markup
data record(CreatedDate = "2025-02-10T20:45:00.000+0000")
| fieldsAdd CreatedTs = toTimestamp(CreatedDate)
| fieldsAdd TokenExpiryDate = CreatedTs + duration(90, "d")

```

 ![t_pawlak_0-1763374959011.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/3/f38cf51a031d5d477760645aeba6bf6fb12e580a.png)

Use two fieldsAdd steps or compute it directly.
