All Forums Third Party Software
TerrorDater 2 posts Joined 11/12
21 Nov 2012
SSRS - querying TD using a VB expression via ODBC

SQL Server 2008 R2 - Reporting Services - Windows Server 2003 sp2
 
I am using BETWEEN in my WHERE clause as part of a VB expression, to power a SSRS report:
"...WHERE CTT.CREATE_TIMESTAMP
BETWEEN
(" & Format(Parameters!parm_DateFrom.Value,"yyyy-MM-dd hh:mm:ss") & ") Timestamp(0)
AND
(" & Format(Parameters!parm_DateTo.Value,"yyyy-MM-dd hh:mm:ss") Timestamp(0)   "
 
BUT this is failing with: "Invalid operation for DateTime or Interval."
However, this query works if I replace the WHERE clause with
"...WHERE CTT.CREATE_TIMESTAMP
BETWEEN
(CURRENT_DATE-14) AND (CURRENT_DATE)..."
Can anyone shed any light on Teradata comparisons regarding Datetime and Date, etc. Coming from a SQL Server background, it is easy to compare Timestamp with Data values and vice-versa.

Fred 1096 posts Joined 08/04
01 Dec 2012

A Teradata/ANSI timestamp literal is preceded by keyword TIMESTAMP and enclosed in apostrophes / single quotes:

TIMESTAMP '2012-11-30 12:34:56'

Or you can cast a character literal to TIMESTAMP(0), in either TD or TD format:

'2012-11-30 12:34:56' (TIMESTAMP(0))
CAST('2012-11-30 12:34:56' AS TIMESTAMP(0))

But your example generates invalid syntax like

(2012-11-30 12:34:56) TIMESTAMP(0)
TerrorDater 2 posts Joined 11/12
24 Jan 2013

School-boy error, thank-you for spotting this. Working with VB expressions makes me overlook single/double quotes.

You must sign in to leave a comment.