SQL date format

  • Thread starter Thread starter Martin
  • Start date Start date
M

Martin

Hi Everyone,

is there a function that i can use to format the date so i can query sql
server.

right now i can only use the mm/dd/yyyy format, but i want to use the
dd/mm/yyyy format.

When i use the dd/mm/yyyy no records are returned or i get an error that the
it's not recognized.

I want to be able to use any date format to query sql server.

Thanks in advance.

Martin.
 
See the instruction "SET DATEFORMAT mdy" in the BOL. For exemple:

SET DATEFORMAT dmy
GO
DECLARE @datevar datetime
SET @datevar = '31/12/98'
SELECT @datevar
GO

You can also set the default language of the user connecting to the database
as French: this will set the default date format to dmy for this user (but
not for the other users). The default language can also be set in the
connection string. Beside the default date format, setting the default
language also changes some other things; see the BOL for more information
under the following items: "SET LANGUAGE" , "sp_helplanguage" and
"syslanguages" .

S. L.
 
Back
Top