Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate days since created table transformer

Leona Vo July 18, 2022

Hi,

In my Table Transformer, I would like to calculate the number of days since Created.

The following select statement produces what you see in the attached.

SELECT FORMATDATE(NOW()), FORMATDATE(T1.'Created') FROM T*

However, the below produces nothing. What am I missing?

SELECT FORMATDATE(NOW()) - FORMATDATE(T1.'Created') FROM T*

Thank you.now.png

 

UPDATE: From one of the online post, I was able to find the answer.

(CAST(ROUND(ceiling(DATEDIFF(DAY,T1.'Created',NOW())))as int))

 

2 answers

1 accepted

4 votes
Answer accepted
Katerina Kovriga _Stiltsoft_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2022

Hi @Leona Vo ,

You may also try the following SQL query:

Tue 6-1.png

SELECT *,
DATEDIFF(day,T1.'Date',"today")
AS 'Date Diff'
FROM T*

Tue 6-2.png

The date format for this example in the Table Transformer macro settings (Settings tab -> Date format) should be set as "m/d/y".

Hope this also helps.

Leona Vo July 20, 2022

Hi @Katerina Kovriga _Stiltsoft_ thank you for your reply. Your solution is much easier to read and understand. It works beautifully. I add ROUND() to the function to produce integer.

SELECT T1.'Created', ROUND(DATEDIFF(day, T1.'Created', "today")) as 'Ticket Age' FROM T*

arijit chatterjee
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 16, 2023

Hi,

Thanks for your post. I also had a similar issue previously but right now i have got the ticket age from your query but next is that i also need that out of the total days say 100 there will be Saturday and Sunday as well , how to reflect correct number of days in Integer excluding Weekends. Any help here will be much appreciated!!

 

Thanks

Arijit

0 votes
Leona Vo July 18, 2022

(CAST(ROUND(ceiling(DATEDIFF(DAY,T1.'Created',NOW())))as int))

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events