$time__() function does not support Rename Column

When I want to use time column(s) with $time__(timecoolumnname) function or using ‘as Time’ to show as local browser time but I can not rename column name. So if you use multiple time column and you can not use same column name then you will get an error. How can we use multiple time columns (showed as local browser time) without error?

SELECT
(CollectDate) as Time,
$time__(ProblemStartDate),  -- Column Name will be automatically as 'time'. Grafana case sensitive so you can use like that
$time__(ProblemEndDate) AS [EndDate],  -- It is not supported and you can not use name as 'time' again.
FROM TableName

Welcome

what error are you getting? Might be due to $time__ which I do not see as a grafana function name

You do not understand the problem. If you have multiple time column and you want to show as grafana time you should specify column as “time” or you should use $time__() function you can only use 1 column as named “time”.

That is by design in that you cannot have 2 identically named columns. Why would you?

I have multiple date columns in UTC but my browser displays in UTC +3 so I want to use automatically display all datetime columns as user’s current browser time. Grafana only displays as browser’s time but only one colum which named “as time”.
For example I want to display data as table and my table includes few datetime columns like below and I want to show them to users as their browser time and I cannot apply Grafana’s “time” conversions.

CollectTimeUTC
ProblemOccurenceTimeUTC
CurrentTimeUTC
LastModifiedTimeUTC

1 Like

what data types are these columns? Also what does the $__time function actually do? I cant find any documentation

I already explained.

These are same operations and same results. We can use for single date column to show as automatically user’s local time setting.

SELECT CollectTimeUTC as time FROM tablename
SELECT $__time(CollectTimeUTC) FROM tablename

We can not use like that:

SELECT CollectTimeUTC as time, ProblemOccurenceTimeUTC as time, CurrentTimeUTC as time, LastModifiedTimeUTC as time FROM tablename
SELECT $__time(CollectTimeUTC), $__time(ProblemOccurenceTimeUTC), $__time(CurrentTimeUTC), $__time(LastModifiedTimeUTC) FROM tablename

you cant do that. probably a bug

1 Like