VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



SQLDate

by James Wilson (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

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.

Inputs
The date to be processed as type DATE.
Assumes
Example SQl Query- SQL = "SELECT * from tblTest" SQL = SQL & " WHERE StartDate = #" & SQLDate(DateToConvert) & "#
Code Returns
A STRING containing the date formatted to the correct criteria.
API Declarations

Rate SQLDate

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

Download this snippet    Add to My Saved Code

SQLDate Comments

No comments have been posted about SQLDate. Why not be the first to post a comment about SQLDate.

Post your comment

Subject:
Message:
0/1000 characters