Jordan Sopher wrote:
> Hello...
>
> I need some help with my SQL syntax, so it account for
> all international date formats. For example, if you set
SQL fornat for which database? They can differ. Here are some...
Public Function SQLFormatDate(ByVal ActualDate As Date, ByVal Database As
enmDatabaseFormat) As String
' Accepts a date input and outputs a database (SQL) specific
' string
If ActualDate = 0 Then
SQLFormatDate = "Null"
Else
Select Case Database
Case dbtMicrosoftAccess:
SQLFormatDate = "#" & Format$(ActualDate, "d-mmm-yyyy") & " " &
Format$(ActualDate, "Long Time") & "#"
Case dbtMicrosoftSQLServer, dbtSybase:
SQLFormatDate = "'" & Format$(ActualDate, "yyyy-mm-dd") & " " &
Format$(ActualDate, "hh:mm:ss.000") & "'"
Case dbtOracle:
SQLFormatDate = "TO_DATE('" & Format$(ActualDate, "mm-dd-yyyy") &
"', 'mm-dd-yyyy')"
Case Else
Err.Raise errdbcUnknownDatabaseFormat, "dbConnection", "The database
format is unknown"
End Select
End If
End Function
>> Stay informed about: SQL Date Between Problem