SQLDate

By | 2002-06-01

Dates in SQl queries often cause problems, as the date must be in the ANSI format whereas dates brought back can be in a different local format. This function simply returns the date in the required format and save having to type Format(DateString, “mm/dd/yy”) every time.

Original Author: James Wilson

Inputs

The date to be processed as type DATE.

Assumptions

Example SQl Query-
SQL = “SELECT * from tblTest”
SQL = SQL & ” WHERE StartDate = #” & SQLDate(DateToConvert) & “#

Returns

A STRING containing the date formatted to the correct criteria.

API Declarations

Code

Public Function SQLDate(ConvertDate As Date) As String
  SQLDate = Format(ConvertDate, "mm/dd/yyyy")
End Function

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.