tentner
tentner

Reputation: 93

DATEADD() does not add to Hours/Minutes/Seconds in Tableau

Found that I am unable to add hours, minutes or seconds to date in Tableau Desktop. Tried :


DateADD('second', 1, #1970-01-01#) gives 1/1/1970 00:00:00  (expected : 1/1/1970 00:00:01)


DateADD('minute', 1, #1970-01-01#) gives 1/1/1970 00:00:00  (expected : 1/1/1970 00:01:00)

    DateADD('hour', 1, #1970-01-01 00:00:00#) gives 1/1/1970 00:00:00 (expected :1/1/1970 01:00:00) 

But adding date works as expected


DateADD('day', 1, #1970-01-01 00:00:00#) gives 1/2/1970 00:00:00

Since I am using epoch date in seconds, the time part is not correctly calculated. The date part is getting calculated correctly. No matter how many seconds/minutes/hours I add, only if there is a change in date part, the change is reflected.

Am I going wrong anywhere? How can I display the correct time?

enter image description here

enter image description here enter image description here

Upvotes: 1

Views: 2219

Answers (1)

AnilGoyal
AnilGoyal

Reputation: 26218

I cannot see why it is not working in your case. It is working perfectly, in mine.

I added two calc fields one having 1 hour addition and another 20 minutes addition. See the result.

enter image description here

EDIT: I got the error in your viz. Instead of formatting the calculated field as date-time, just click the pill, select 'exact date' instead of 'day' (in your view it is clear you're showing day of calculated field instead of calculated field) click again and select discreet. And your problem should be solved.

enter image description here

You're doing this instead

enter image description here

Upvotes: 1

Related Questions