convert epoch time to date in data tools report expression
I apologize as I'm just getting started with ssrs data tools. I'm trying to report on a successful query column in a report that contains date in epoch time. In the report section of ssdt, it looks like I should be able to create a new column and then put an expression in that column that will convert the epoch column contents to a more convenient format. I see the available expression function "dateadd" and have looked at lots of examples, but when I try this, I get various errors. =dateadd("s",1264769610,'1970-01-01 00:00:00') is one attempt, just using the value 1264769610 to test out a known number of seconds. This gets the error definition of the report is invalid. The value expression for the textrun "Textbox13.Paragraphs[0].TextRuns[0] contains an error: [BC30201] Expression expected. Which makes me think what I've tried is not even recognized as an expression. Can someone help me get the wheels on the bus so I have a chance of getting this bus on the road? Thanks!
September 13th, 2012 10:16am

Perhaps you can use DateInterval class and choose seconds? Like DateAdd(DateInterval.Date, 1, Parameters!Date.Value)Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/ MS SQL optimization: MS SQL Development and Optimization MS SQL Blog: Large scale of database and data cleansing MS SQL Consultants: Improves MS SQL Database Performance
Free Windows Admin Tool Kit Click here and download it now
September 13th, 2012 10:42am

If my memory doesn't fail, the 1970-01-01 date should be enclosed with double quotes, not apostrophesSebastian Sajaroff Senior DBA Pharmacies Jean Coutu
September 13th, 2012 10:48am

Thanks, it turned out to be a syntax error, as you mentioned. The helpful hints on MSDN and other locations seem to be a little inconsistent on syntax. Here's the one that worked for me when writing the expression that converts a know column of epoch report dates to a column of standard format date/time. =DateAdd("s",Fields!F_WXYZ.Value-21600,"1970-01-01 00:00:00") Where the "-21600" is the number of seconds subtracted off to create the time in the correct time zone. The examples I found either had no quotes around the first argument s, and the last argument, 1970-01-01 00:00:00, or they had single quotes. My current superstition is that both need double quotes in this situation of ssdt 2012.
Free Windows Admin Tool Kit Click here and download it now
September 13th, 2012 2:22pm

This takes care of the case where I have a successful query and then convert the epoch values to a more intuitive date I do have another question along these lines. Ultimately, I will need to have the user pass @StartDate and @EndDate to the report and I see where, if I had a table of conventional dates, this would be a snap. However, instead of just having my query being >=@StartDate AND < @EndDate, it looks like I'll need to convert to a filter on the epoch values in my table. Any suggestions of how this might work?
September 13th, 2012 2:38pm

your query would have something like this in the where clause: where ..... and dateadd(second,F_WXYZ-21600,'1970-01-01 00:00:00') between @StartDate and @EndDateThink out of the box
Free Windows Admin Tool Kit Click here and download it now
September 13th, 2012 4:24pm

your query would have something like this in the where clause: where ..... and dateadd(second,F_WXYZ-21600,'1970-01-01 00:00:00') between @StartDate and @EndDateThink out of the box
September 13th, 2012 4:41pm

Thanks i_h. Very efficient!
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 4:30pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics