GetDBDate – Formatting a date as a DateSerial for Access

' Format a date as a DateSerial for Access' Example: Debug.Print GetDBDate(date)Public Function GetDBDate(sDate As String) As String   On Error GoTo ERROR_GetDBDate   Dim sTmp As String   If IsDate(sDate) = False Then      sTmp = sDate   Else      sTmp = "DateSerial(" & Year(sDate) & ", " & Month(sDate) & ", " & Day _          (sDate) & ")"   End IfEXIT_GetDBDate:   GetDBDate = sTmp   Exit FunctionERROR_GetDBDate:   sTmp = sDate   Resume EXIT_GetDBDateEnd Function'========================================' You can find more routines like this on www.vbdiamond.com,'  a site devoted to  VB developers'========================================

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: