Cannot convert from Db.DateTimeOffset to Td.TimeStampWithZone

Connectivity
Enthusiast

Cannot convert from Db.DateTimeOffset to Td.TimeStampWithZone

I am attempting to execute a parametrized non-query SQL command using TdCommand.ExecuteNonQuery().  The parameter in question is DbType.DateTimeOffset and TdType.TimestampWithZone; the parameter value was generated using DateTime.Now and appears to be completely defined (as verified via the Visual Studio debugger).  When I reach my ExecuteNonQuery() statement, I receive a System.InvalidCastException with message "Cannot convert to Timestamp with Time Zone".  The command text, for what it's worth, is simply: "INSERT INTO DateTimeOffsetTable (DateTimeOffsetVal) VALUES(?);".  

The Teradata Configuring Parameters and Parameter Data Types page suggests that DateTimeOffset should map to TimeStampWithZone; however it also indicates that inference from DateTime2 is not supported.  Not sure if it matters, but the Date/Time data types description provided by Microsoft (http://msdn.microsoft.com/en-us/library/bb675168(v=vs.110).aspx), however, says "The datetimeoffset data type has all the features of datetime2 with an additional time zone offset."  Would this affect the conversion?  If not, any suggestions how to remedy the issue?

Tags (3)
1 REPLY
Teradata Employee

Re: Cannot convert from Db.DateTimeOffset to Td.TimeStampWithZone

You wrote

the parameter value was generated using DateTime.Now 

change it to DateTimeOffset.Now.