[dba-SQLServer] [dba-sqlserver] FncStrDateSQL

Borge Hansen pcs.accessd at gmail.com
Thu Jul 10 20:35:28 CDT 2008


Hi,
I was thinking: ... shall I search the archives ... or .... shall I shoot a
quick message ...

What's the equivalent to Gustav's very helpful function (see below) of
formatting dates for use in queries when you are working with views / sp in
SQL2005 ??

Public Function FncStrDateSQL(ByVal dat As Date) As String
' Formats full string of date/time in US format for SQL.
' Overrides local (non US) settings for date/time separators.
' Example output:    #08/16/1998 04:03:36 PM#
' 1999-10-21. Cactus Data ApS, CPH.
      FncStrDateSQL = Format(dat, "\#mm\/dd\/yyyy hh\:nn\:ss AM/PM\#")
End Function

I need to be able to do > ; >=; <; <= comparisons being secure in my sleep
that a '7-Mar-2008' doesn't get interpreted as a '3-Jul-2008'

Gustav?

regards
Borge



More information about the dba-SQLServer mailing list