Amr Elgarhy
Amr Elgarhy

Reputation: 68892

How to read and update a datetimeoffset field using classic asp?

I have a field in sql server 2014 db with datatype DateTimeOffset, how to create a proper Datetimeoffset using classic asp to update this field?
For example I have a 2 variables first one has the datetime and the second one has the offset and I want to combine both to put in the Datetimeoffset db field.

And also how to read from Datetimeoffset db field as datetime in classic asp?

Upvotes: 2

Views: 599

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241420

The primary data access mechanism for Classic ASP is ADO. This is used from ASP, VBScript, and VB6.

To get support for the datetimeoffset type, and other newer features of SQL Server, you need to use the SQL Native Client as the underlying data provider for ADO. Simply set both Provider=SQLNCLI11 and DataTypeCompatibility=80 in your connection string, as described in the MSDN here.

Then you can simply interact with your datetimeoffset field like you would any other. Since all VBScript variables are Variant typed, and there's no variant subtype for DateTimeOffset, the field value will be mapped to a Variant with a String subtype. The string representation is similar to 2015-12-27 19:51:35.4005420 -08:00, where the number of decimals corresponds to the precision of the field in your database.

Upvotes: 1

Related Questions