DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Calculate expiration date

orchidee
Newcomer

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 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. 

1 REPLY 1

t_pawlak
Champion

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:

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

Use two fieldsAdd steps or compute it directly.

Featured Posts