Logo
Home Cart [Log In] About Us Contact Us

Object Reference

xf_DbConnectDatabase Access Wrapper

Public Function DateToSQLText (
d,
Optional DateBoundary As xf_DateBoundaryEnum = 1
) As String

Convert a date to text suitable for use in an SQL query, including date delimiters. Returns text dates (eg. 21 Nov 2011) so that the information is unambiguous. JET SQL always assumes U.S. date format (eg. mm/dd/yyyy) even though the query editor will display the date in your regional format.
# is used to delimit dates in JET, and ' in MSSQL The date passed is a variant, and a Null value returns the string: NULL

d as Variant

The date

Optional DateBoundary as xf_DateBoundaryEnum = 1

Used for date compares since the default 'date only' time is 12:00am. #2 Jan 2000 15:30# <= #2 Jan 2000# evaluates as false even though the dates are same because it translates as #2 Jan 2000 15:30# <= #2 Jan 2000 0:00# To match any date less than or equal to the date specified (the second date above), use 'xf_DateBoundary_EndOfDay' flag to force #2 Jan 2000 15:30# <= #2 Jan 2000 23:59:59# = true OR use 'xf_DateBoundary_NextDay' flag to return the next day and use < rather than <= ie. #2 Jan 2000 15:30# < #3 Jan 2000 0:00#

Call Template:

Dim s As String
s = xf.DbConnect.DateToSQLText(d)
s = xf.DbConnect.DateToSQLText(d, DateBoundary)

See Also:

Example 1:

Dim d as Date
d = #23/2/1982#
Debug.Print xf.DbConnect.DateToSQLText(d)
#23 Feb 1982#   (in Australia!)
Contact Us :: About Us :: Policies :: email: infspamo@arrospamw-of-tispamme.com    © 2012 Arrow Of Time Pty Ltd