[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Help with DATE data type conversion

John Cosmas

4/12/2005 1:28:00 PM

I've encountered a table that stores dates in Gregorian format so that the
dates and time looks like straight integers that cannot be easily discrened
as a date or time by just looking at it. I'm using SQL to query the table
and retrieve the data as an integer. I'm tyring to figure out how to best
CAST or CONVERT the field into a DATE type so that its readable in the right
format. I'm coding in VB.NET and the use of CDATE and FORMAT have both been
futile. I realize this is a simple question, but I'm kindly lost so I'm
trying not to loose it by spinning my wheels too hard.

John


1 Answer

Cor Ligthert [MVP]

4/13/2005 10:10:00 AM

0

John,

The datetime format is a long that exist from ticks. For the SQLserver
datetime there is a different starting point than for the system.datetime.
The first start with the Georgian calendar in 1753 and the other in the year
1. (1753 was the point where the UK (and therefore there colonies) switched
from Julian to Georgian)

With CDate that is converted right so that is not the problem.

When you want the date as value, than you can use something like this
roughly written

\\dim dtFromSQL as datetime = CDate(dr("DateTime"))
dim dtLong as long = dtfromSQL.Ticks
///

I hope this helps,

Cor