SmartDate and DateTimeOffset

SmartDate and DateTimeOffset

Old forum URL:

GregDobbs posted on Wednesday, January 13, 2010

Hello all.

I've been unable to get SmartDate to persist DateTimeOffset values to the database.

Property Definition:

Public Shared RegistrationDateProperty As PropertyInfo(Of SmartDate) = RegisterProperty(New PropertyInfo(Of SmartDate)("RegistrationDate"))
Public Property RegistrationDate() As String
Return GetPropertyConvert(Of SmartDate, String)(RegistrationDateProperty)
End Get
Set(ByVal value As String)
SetPropertyConvert(Of SmartDate, String)(RegistrationDateProperty, value)
End Set
End Property

Insert Parameter:

cm.Parameters.AddWithValue("@RegistrationDate", ReadProperty(RegistrationDateProperty).DBValue)

The above result in a standard datetime value being inserted into SQL Server - the offset value is ignored.

Anyone else handled this issue?


RockfordLhotka replied on Wednesday, January 13, 2010

SmartDate internally uses a DateTime to store its information. It is a wrapper around DateTime, so the behavior you observe is correct.

SmartDate is convertible to/from other date types such as DateTimeOffset, but internally it doesn't maintain its information in that type.

GregDobbs replied on Thursday, January 14, 2010

Thanks for the response, Rocky.

I guess my choices are 1) to modify the internal structure of SmartDate so it stores DateTimeOffset by default or 2) perhaps create my own version such as SmartDateOffset.

RockfordLhotka replied on Thursday, January 14, 2010

Yes, I think that is a fair summary.

Kyle replied on Wednesday, October 13, 2010

It's been a while since anyone posted to this thread. I see that Rocky has put in SmartDateOffset as a future feature. Has anyone already coded (and tested) something that they could share in the meantime?


Copyright (c) Marimer LLC