Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB4/32, VB5, VB6, SQL Server 6.5+, Oracle 8i+
Expertise: Beginner
Nov 15, 2003



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Compare Oracle and SQL Server Dates

Oracle and SQL Server databases use different date/time resolutions, which poses a problem when you compare times from the two databases: The times will rarely be equal. Solve this problem by allowing for a margin of error. Treat the dates and times as floating-point numbers and remember that each day is equal to the whole number 1, and there are 86,400 seconds in a day. This function matches times within five seconds (default) of one another:

Public Function MatchTime(adoFldOracle As ADODB.Field, _
	adoFldSQLServer As ADODB.Field, _
	Optional ByVal Tolerance As Long = 5) As Boolean

	Dim dtOracle As Date
	Dim dtSQLServer As Date
	Dim dblTolerance As Double
	Const OneSecond As Double = 1 / 86400

	dblTolerance = OneSecond * Tolerance
	dtOracle = adoFldOracle.Value
	dtSQLServer = adoFldSQLServer.Value
	If ((dtOracle > (dtSQLServer + dblTolerance)) Or _
		(dtOracle < (dtSQLServer - dblTolerance))) Then
		MatchTime = False
		MatchTime = True
	End If
End Function
Andy Clark, Richmond, Va.
Andy Clark
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date