How to Display User Specific Time in Excel Header using Dashboard XFBR String

Rithik_Prem
New Contributor III

Hi,

We are trying to Display User Time when we export the report to excel on Excel Header. We tried using this code, but it is giving us the UTC Time.

If args.FunctionName.XFEqualsIgnoreCase("DateandTime") Then
Dim localTime As DateTime = DateTime.UtcNow
Dim timeZone As TimeZone = TimeZone.CurrentTimeZone
localTime = timeZone.ToLocalTime(localTime)
Dim formattedTime As String = localTime.ToString("yyyy-MM-dd HH:mm:ss")
Return formattedTime
End If
 
Is there any way to display the User specific Time?
Thank you

 

 

1 REPLY 1

RobbSalzmann
Valued Contributor

Since the XFBR code runs on the OneStream Server the server's Timezone will always be what is returned by  TimeZone.CurrentTimeZone.

To use user TimeZones:
Store each user's three char time zone in one of the User account Text fields.

Then use the following code to look it up and use the TZ in your code above:

 

 

Dim strTimeZone as String = BRApi.Security.Authorization.GetUser(si, si.UserName).User.Text1;

 

 

RobbSalzmann_1-1695215680840.png

 

 

Software Architect
MindStream Analytics
"Difficult done right away. Impossible takes a bit longer"