Showing posts with label english. Show all posts
Showing posts with label english. Show all posts

Sunday, March 25, 2012

Date Problem

Dear All,
I am using British English for my database. I am using the following
function to convert the date
CONVERT(varchar(20),'04/10/2003',23)
and its returning me 2003-04-10 which I dont want. The format which I
require is
2003-10-04 (yyyy-mm-dd).
Any help will be much appreciated.
Thanking you in anticipation.
cheers,
Sunil SabirYour Date is ambigious to SQL Server. Even though you are using Britsh
English, the date will be stored in the correct format, however it will
convert your ambigious date defaulting the format to mm/dd/yyyy.
SELECT CONVERT(VARCHAR(20),CAST('10/4/2003' AS DATETIME), 23)
This is ambiguous and will return 2003-10-04
SELECT CONVERT(VARCHAR(20),CAST('10/APRIL/2003' AS DATETIME), 23)
This is not ambiguous and will return 2003-04-10
SELECT CONVERT(VARCHAR(20),CAST('04/10/2003' AS DATETIME), 23)
This is not ambiguous and will return 2003-04-10
Hope this helps
Andy
I would suggest either using a non ambiguous date format such as yyyy-mm-dd
"Sunil Sabir" wrote:

> Dear All,
> I am using British English for my database. I am using the following
> function to convert the date
> CONVERT(varchar(20),'04/10/2003',23)
> and its returning me 2003-04-10 which I dont want. The format which I
> require is
> 2003-10-04 (yyyy-mm-dd).
> Any help will be much appreciated.
> Thanking you in anticipation.
> cheers,
> Sunil Sabir
>|||Hi
Have a look at: http://www.karaszi.com/sqlserver/info_datetime.asp
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Sunil Sabir" wrote:

> Dear All,
> I am using British English for my database. I am using the following
> function to convert the date
> CONVERT(varchar(20),'04/10/2003',23)
> and its returning me 2003-04-10 which I dont want. The format which I
> require is
> 2003-10-04 (yyyy-mm-dd).
> Any help will be much appreciated.
> Thanking you in anticipation.
> cheers,
> Sunil Sabir
>|||hi
Probably yo can try this
SET DATEFORMAT dmy
SELECT convert (varchar(20), cast('04/10/2003' as datetime),23)
Probable this solves the problem. the key here is SET DATEFORMAT dmy
please revert back if u have any questions
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Sunil Sabir" wrote:

> Dear All,
> I am using British English for my database. I am using the following
> function to convert the date
> CONVERT(varchar(20),'04/10/2003',23)
> and its returning me 2003-04-10 which I dont want. The format which I
> require is
> 2003-10-04 (yyyy-mm-dd).
> Any help will be much appreciated.
> Thanking you in anticipation.
> cheers,
> Sunil Sabir
>|||> I am using British English for my database. I am using the following
> function to convert the date
> CONVERT(varchar(20),'04/10/2003',23)
Are you really hard-coding this date from 2+ years ago in your statement?
Or is your real query working against a table?
If you are hard-coding the statement, you should always use unambiguous date
formats that are language-neutral, are not affected by regional settings,
and are safe from dateformat settings (never mind absolutely clear to every
human who looks at them, regardless of which country they are from).
If you are really working against a table, you should be clear that in
DATETIME / SMALLDATETIME columns, the date is NOT stored in the format you
describe, even though that may be what Enterprise Manager or other graphical
query tools will present to you.

> and its returning me 2003-04-10 which I dont want. The format which I
> require is
> 2003-10-04 (yyyy-mm-dd).
So either enter the date in an unambiguous way:
DECLARE @.d SMALLDATETIME
SET @.d = '20031004'
SELECT CONVERT(CHAR(10), @.d, 120)
Or else explicitly convert it first:
DECLARE @.d SMALLDATETIME
SET @.d = CONVERT(DATETIME, '04/10/2003', 103)
SELECT CONVERT(CHAR(10), @.d, 120)
Please have a look at these articles:
http://www.aspfaq.com/2023
http://www.karaszi.com/SQLServer/info_datetime.asp|||Dear SIr,
I tried to follow your instructions but it still showing me 2003-04-10. I
tried changing the DATEFORMAT but same problem. any more ideas. I am passin
g
the date as a parameter through a stored procedure below is the syntax
''''+CONVERT(varchar(20),CAST(@.inputTrai
ningDate as datetime),23)+'''
Your help would be greatly appreciated.
thanks,
Sunil Sabir
"Chandra" wrote:
> hi
> Probably yo can try this
> SET DATEFORMAT dmy
> SELECT convert (varchar(20), cast('04/10/2003' as datetime),23)
> Probable this solves the problem. the key here is SET DATEFORMAT dmy
> please revert back if u have any questions
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://groups.msn.com/SQLResource/
> ---
>
> "Sunil Sabir" wrote:
>|||gi sunil
''''+CONVERT(varchar(20),CAST(@.inputTrai
ningDate as datetime),23)+'''
works fine. If @.inputTrainingDate is of type date, then u need not convert
it here
it can be written as
''''+CONVERT(varchar(20), @.inputTrainingDate ,23)+'''
see that you use "SET DATEFORMAT dmy"
in the stored procedure.
just see this:
declare @.date as datetime
SET DATEFORMAT dmy
SET @.date = '04/10/2003'
SELECT CONVERT(carchar(20), @.date, 23)
displays: 2003-10-04
please let me know if u still have a problem.
just send the SP script if u have a problem
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Sunil Sabir" wrote:
> Dear SIr,
> I tried to follow your instructions but it still showing me 2003-04-10. I
> tried changing the DATEFORMAT but same problem. any more ideas. I am pass
ing
> the date as a parameter through a stored procedure below is the syntax
> ''''+CONVERT(varchar(20),CAST(@.inputTrai
ningDate as datetime),23)+'''
> Your help would be greatly appreciated.
> thanks,
> Sunil Sabir
> "Chandra" wrote:
>|||Dear Sir,
Dear Sir,
Thanks for your prompt reply. The problem is that when I execute SET DATE
FORMAT before the stored procedure it works fine and shows me 2003-10-04 .if
i want to retrieve any records from the DB with respect to this date. It
doest show me anything in the results pane of the QUERY analyzer. For exampl
e
select first name from database where date = '2003-10-04'
But when i post the above query in the VIEW of Enterprise manager it does
show me records. and the strange thing is that when I change the date back t
o
2003-04-10 in the query analyzer it starts working. I am very dont
know whats happening.
Please help me . I will be very grateful to you.
cheers,
Sunil Sabir
"Chandra" wrote:
> gi sunil
> ''''+CONVERT(varchar(20),CAST(@.inputTrai
ningDate as datetime),23)+'''
> works fine. If @.inputTrainingDate is of type date, then u need not conver
t
> it here
> it can be written as
> ''''+CONVERT(varchar(20), @.inputTrainingDate ,23)+'''
> see that you use "SET DATEFORMAT dmy"
> in the stored procedure.
> just see this:
> declare @.date as datetime
> SET DATEFORMAT dmy
> SET @.date = '04/10/2003'
> SELECT CONVERT(carchar(20), @.date, 23)
> displays: 2003-10-04
> please let me know if u still have a problem.
>
> just send the SP script if u have a problem
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://groups.msn.com/SQLResource/
> ---
>
> "Sunil Sabir" wrote:
>|||Egads. Stop passing in bad date formats and your problem will disappear.
"Sunil Sabir" <SunilSabir@.discussions.microsoft.com> wrote in message
news:178212DA-215A-4050-A6F4-975CD9520E21@.microsoft.com...
> Dear Sir,
> Dear Sir,
> Thanks for your prompt reply. The problem is that when I execute SET DATE
> FORMAT before the stored procedure it works fine and shows me 2003-10-04
> .if
> i want to retrieve any records from the DB with respect to this date. It
> doest show me anything in the results pane of the QUERY analyzer. For
> example
> select first name from database where date = '2003-10-04'
> But when i post the above query in the VIEW of Enterprise manager it does
> show me records. and the strange thing is that when I change the date back
> to
> 2003-04-10 in the query analyzer it starts working. I am very
> dont
> know whats happening.
> Please help me . I will be very grateful to you.
> cheers,
> Sunil Sabir
>
> "Chandra" wrote:
>|||So how do I do it'
Please Help
"Aaron Bertrand [SQL Server MVP]" wrote:

> Egads. Stop passing in bad date formats and your problem will disappear.
>
> "Sunil Sabir" <SunilSabir@.discussions.microsoft.com> wrote in message
> news:178212DA-215A-4050-A6F4-975CD9520E21@.microsoft.com...
>
>sql

Sunday, March 11, 2012

date formatting or localization

I have written this ugly expression because I didn't know any other way. What I am trying to do is convert an English date string to a French string.

example

January 2005 > Janvier 2005

Thank you,

Pavel

=Switch(

Month(CDate(Fields!Month.Value) ) = 1, "Janvier" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 2, "Fevrier" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 3, "Mars" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 4, "Avril" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 5, "Mai" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 6, "Juin" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 7, "Juillet" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 8, "Aout" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 9, "September" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 10, "Octobre" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 11, "November" & " " & Year(CDate(Fields!Month.Value)),
Month(CDate(Fields!Month.Value) ) = 12, "December" & " " & Year(CDate(Fields!Month.Value))

)The only thing I see wrong with this is that you have Year(CDate(Fields!Month.Value) and that will not produce a result, correct?|||The field Month.Value stores "January 2004". I get the value from Analysis Services.

Pavel

Thursday, March 8, 2012

Date Format Problem in SQL

Hi
My Application is designed for 5
languages.English,Spain,France,Japan and Germany.
It works fine for all other 4 languages except France.The
Problem is When Retreiving data from the database i get
an error "Arithmatic Overflow of data of datatype DateTime.
The same Application it works for france in my location
but at the vendor location it fails.we have changed all
the configuration setting(To France Setting(regional
setting and have installed the SQL Server in France as
default language) but still it works fine in our
Location.We have tried running the Application by
replicating their database, we dont face any problem here.
It will be grate ful if you provide solution for this.Is
that in the vendor site they have to install the lastest
service pack version or any thing else to do with the SQL
Server setting in France(because in all other vendor
locations(Spain,Germany,Japan) works fine.Please suggest
some solution for this.
Thanks and Regards,
SumathiHi Sumathi,
I didn't get chance of working on multiple languages.
But, the concept is this:
Installations of localized versions of SQL Server
install the translated set of messages in addition to the
English set. When SQL Server sends a message to a
connection, it uses the localized message if the language
ID of the connection matches one of the language IDs
present in sysmessages. If there is no message in
sysmessages with the same language ID, the English version
of the message is sent.
Please check the "sysmessages" and "syslanguages" and
see whether you have language ID for French.
Also, its always good to keep the all servers with same
service pack level (latest SP3).
Hope this may help you to start with debugging this issue.
Appreciate response if this suggestion helps.
-Varad
>--Original Message--
>Hi
> My Application is designed for 5
>languages.English,Spain,France,Japan and Germany.
>It works fine for all other 4 languages except France.The
>Problem is When Retreiving data from the database i get
>an error "Arithmatic Overflow of data of datatype
DateTime.
>The same Application it works for france in my location
>but at the vendor location it fails.we have changed all
>the configuration setting(To France Setting(regional
>setting and have installed the SQL Server in France as
>default language) but still it works fine in our
>Location.We have tried running the Application by
>replicating their database, we dont face any problem
here.
>It will be grate ful if you provide solution for this.Is
>that in the vendor site they have to install the lastest
>service pack version or any thing else to do with the SQL
>Server setting in France(because in all other vendor
>locations(Spain,Germany,Japan) works fine.Please suggest
>some solution for this.
>Thanks and Regards,
> Sumathi
>.
>

Date format in Sql Server 2000 italian and english

I have a Sql Server 2000 installation and my server is Win2k sp2
English.
If i run a query with WHERE condition, for example,

SELECT * FROM TABLE WHERE DATEOFBIRTH ='2004-01-15'

my resultset contain the records correct.

But the results with the same query, which run on a Sql Server 2000
installation with same collation and a server Win2k Italian, is:
'La conversione del tipo di dati da char a datetime ha generato un
valore di tipo datetime non compreso
nell'intervallo di valori validi.'

English error:
'Converting data type from char to datetime has generated a datetime
value that is out of range of valid values'

It is not possible to change all query in my client application.

How I can have the same results for the same query in both
installations?

Thanks in advantage

MaurizioSELECT *
FROM table
WHERE dateofbirth ='20040115'

--
David Portas
SQL Server MVP
--|||SELECT *
FROM table
WHERE dateofbirth ='20040115'

--
David Portas
SQL Server MVP
--|||Maurizio Fazio (maurizio.fazio@.gmail.com) writes:
> I have a Sql Server 2000 installation and my server is Win2k sp2
> English.
> If i run a query with WHERE condition, for example,
> SELECT * FROM TABLE WHERE DATEOFBIRTH ='2004-01-15'
> my resultset contain the records correct.
> But the results with the same query, which run on a Sql Server 2000
> installation with same collation and a server Win2k Italian, is:
> 'La conversione del tipo di dati da char a datetime ha generato un
> valore di tipo datetime non compreso
> nell'intervallo di valori validi.'
> English error:
> 'Converting data type from char to datetime has generated a datetime
> value that is out of range of valid values'
> It is not possible to change all query in my client application.
> How I can have the same results for the same query in both
> installations?

In addition to David's response, check out this article for the
gory details: http://www.karaszi.com/SQLServer/info_datetime.asp.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Wednesday, March 7, 2012

date format in parameter

In my report I am filtering results depending on a date range, I have the default language of my report set to English (United Kingdom), however my parameters fail to recognise a date such as 13/01/2005 and displays an error message, however if I change the date to 01/13/2005 it filters the results correctly.
The actual date which appears in my results is formatted correctly.
Is there anything I can do to rectify the format in the parameter value?I suppose you have a English US setting on you database.
I also suppose reinstalling the databaseserver would not be an optionWink [;)]
I'd say you convert the dates in between your application and the database and pass the dates as strings to your database (MM/DD/YYYY) but what usually works as well and always is interpreted correctly is YYYY-MM-DD (HH:MM:SS).
In that output setting the days and the months never get mixed (not that i know of anyway).
I haven't found a way in SQL Server to change that setting, but if you do, just let me know, i certainly could mage good use of it Smile [:)]
btw change the setting without reinstalling it off course.|||This may or may not help!
But here is a Standard Date Formatter UDF that accepts dates in a lot of different formats and returns a value.
If necessary I think you could modify to ensure that whatever date format the User enters you can call the UDF and get a standard date formate back to use within your SQL to ensure you get the ranges for the date (in almost whatever format) they entered the date in via the parameter.
CREATE FUNCTION dbo.fn_FormatDateTime
(
@.dt DATETIME,
@.format VARCHAR(16)
)
RETURNS VARCHAR(64)
AS
BEGIN
DECLARE @.dtVC VARCHAR(64)
SELECT @.dtVC = CASE @.format

WHEN 'LONGDATE' THEN

DATENAME(dw, @.dt)
+ ',' + SPACE(1) + DATENAME(m, @.dt)
+ SPACE(1) + CAST(DAY(@.dt) AS VARCHAR(2))
+ ',' + SPACE(1) + CAST(YEAR(@.dt) AS CHAR(4))

WHEN 'LONGDATEANDTIME' THEN

DATENAME(dw, @.dt)
+ ',' + SPACE(1) + DATENAME(m, @.dt)
+ SPACE(1) + CAST(DAY(@.dt) AS VARCHAR(2))
+ ',' + SPACE(1) + CAST(YEAR(@.dt) AS CHAR(4))
+ SPACE(1) + RIGHT(CONVERT(CHAR(20),
@.dt - CONVERT(DATETIME, CONVERT(CHAR(8),
@.dt, 112)), 22), 11)

WHEN 'SHORTDATE' THEN

LEFT(CONVERT(CHAR(19), @.dt, 0), 11)

WHEN 'SHORTDATEANDTIME' THEN

REPLACE(REPLACE(CONVERT(CHAR(19), @.dt, 0),
'AM', ' AM'), 'PM', ' PM')

WHEN 'UNIXTIMESTAMP' THEN

CAST(DATEDIFF(SECOND, '19700101', @.dt)
AS VARCHAR(64))

WHEN 'YYYYMMDD' THEN

CONVERT(CHAR(8), @.dt, 112)

WHEN 'YYYY-MM-DD' THEN

CONVERT(CHAR(10), @.dt, 23)

WHEN 'YYMMDD' THEN

CONVERT(VARCHAR(8), @.dt, 12)

WHEN 'YY-MM-DD' THEN

STUFF(STUFF(CONVERT(VARCHAR(8), @.dt, 12),
5, 0, '-'), 3, 0, '-')

WHEN 'MMDDYY' THEN

REPLACE(CONVERT(CHAR(8), @.dt, 10), '-', SPACE(0))

WHEN 'MM-DD-YY' THEN

CONVERT(CHAR(8), @.dt, 10)

WHEN 'MM/DD/YY' THEN

CONVERT(CHAR(8), @.dt, 1)

WHEN 'MM/DD/YYYY' THEN

CONVERT(CHAR(10), @.dt, 101)

WHEN 'DDMMYY' THEN

REPLACE(CONVERT(CHAR(8), @.dt, 3), '/', SPACE(0))

WHEN 'DD-MM-YY' THEN

REPLACE(CONVERT(CHAR(8), @.dt, 3), '/', '-')

WHEN 'DD/MM/YY' THEN

CONVERT(CHAR(8), @.dt, 3)

WHEN 'DD/MM/YYYY' THEN

CONVERT(CHAR(10), @.dt, 103)

WHEN 'HH:MM:SS 24' THEN

CONVERT(CHAR(8), @.dt, 8)

WHEN 'HH:MM 24' THEN

LEFT(CONVERT(VARCHAR(8), @.dt, 8), 5)

WHEN 'HH:MM:SS 12' THEN

LTRIM(RIGHT(CONVERT(VARCHAR(20), @.dt, 22), 11))

WHEN 'HH:MM 12' THEN

LTRIM(SUBSTRING(CONVERT(
VARCHAR(20), @.dt, 22), 10, 5)
+ RIGHT(CONVERT(VARCHAR(20), @.dt, 22), 3))

ELSE

'Invalid format specified'

END
RETURN @.dtVC
END
Maybe this is a starting point that you can work with!
Best Regards,
Joe|||Sorry - but sometimes I thake things for granted!!
When I define a parameter within Reporting Services and the parameter is a date - I just define define the date parameter as a string - then pass the parameter to my SQL (a stored procedure) and then go from there.
So the UDF that I gave you would allow you to define a value and on the fly convert so you then can compare the passed date parameter in the format you want (reformatted against the UDF) against the dates within your table.
One other thing, I think that within your SP - you take the date that was given as a parameter, convert to the format you want and use ISDATE to determine if the parameter is a valid date and if not have a "variable" field that always gets passed back to RS - (just like within SQL and you want to do a global count - EXPR) and if the date is invalid pop a value within the variable field as invalid date or whatever - if not carry on!
I have the same problem (kind of) here in Bangkok in that their yearly calendar is 543 years ahead of a Western calendar so for todays date 7/22/2005 in comes in as a parameter as 7/22/2548 or 22/7/2548 so I always have to inspect what format MM/DD/YYYY or DD/MM/YYYY and then inspect the YYYY to determine if in Thai years then subtract 543 or leave alone.
Hope I have been clear enough!
Best Regards,
Joe

Date Format - SQL Server 2000

If date format is set by default language and the default language is set to
English and English has a mdy format, why would dates come out as ymd when
queried? Is it possible to set the date format on server level so that
whenever a user runs a query it comes out in mm/dd/yyyy format? I know I can
convert it to string then change the format but I don't want that option.
Please help..."Bob" <Bob@.discussions.microsoft.com> wrote in message
news:92CD54E6-1182-410B-A995-973737A7238D@.microsoft.com...
> If date format is set by default language and the default language is set
> to
> English and English has a mdy format, why would dates come out as ymd when
> queried? Is it possible to set the date format on server level so that
> whenever a user runs a query it comes out in mm/dd/yyyy format? I know I
> can
> convert it to string then change the format but I don't want that option.
> Please help...
SQL Server has no control over how dates are displayed in your client
application. You need to configure that setting client-side, either in the
Windows Control Panel or in the client application or your development
environment.
SQL Server does have the LANGUAGE and DATEFORMAT settings but they purely
control how strings get converted to dates. Those settings do not control
how dates get displayed by client applications.
You could convert your dates to strings and return those string values to
the client as a way of controlling the format. I think that's a bad idea
however. For one thing it means you can't maniplulate the values as proper
dates any more. For another, IMO it is inconsiderate to force the user to
live with the format that you prefer.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||That's what I thought too. Just wanted to confirm. Thanks for your help.
"David Portas" wrote:
> "Bob" <Bob@.discussions.microsoft.com> wrote in message
> news:92CD54E6-1182-410B-A995-973737A7238D@.microsoft.com...
> > If date format is set by default language and the default language is set
> > to
> > English and English has a mdy format, why would dates come out as ymd when
> > queried? Is it possible to set the date format on server level so that
> > whenever a user runs a query it comes out in mm/dd/yyyy format? I know I
> > can
> > convert it to string then change the format but I don't want that option.
> > Please help...
> SQL Server has no control over how dates are displayed in your client
> application. You need to configure that setting client-side, either in the
> Windows Control Panel or in the client application or your development
> environment.
> SQL Server does have the LANGUAGE and DATEFORMAT settings but they purely
> control how strings get converted to dates. Those settings do not control
> how dates get displayed by client applications.
> You could convert your dates to strings and return those string values to
> the client as a way of controlling the format. I think that's a bad idea
> however. For one thing it means you can't maniplulate the values as proper
> dates any more. For another, IMO it is inconsiderate to force the user to
> live with the format that you prefer.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>
>|||You can set the date format on a session level..
SET DATEFORMAT ydm
"Bob" <Bob@.discussions.microsoft.com> wrote in message
news:92CD54E6-1182-410B-A995-973737A7238D@.microsoft.com...
> If date format is set by default language and the default language is set
> to
> English and English has a mdy format, why would dates come out as ymd when
> queried? Is it possible to set the date format on server level so that
> whenever a user runs a query it comes out in mm/dd/yyyy format? I know I
> can
> convert it to string then change the format but I don't want that option.
> Please help...

Date Format - SQL Server 2000

If date format is set by default language and the default language is set to
English and English has a mdy format, why would dates come out as ymd when
queried? Is it possible to set the date format on server level so that
whenever a user runs a query it comes out in mm/dd/yyyy format? I know I can
convert it to string then change the format but I don't want that option.
Please help..."Bob" <Bob@.discussions.microsoft.com> wrote in message
news:92CD54E6-1182-410B-A995-973737A7238D@.microsoft.com...
> If date format is set by default language and the default language is set
> to
> English and English has a mdy format, why would dates come out as ymd when
> queried? Is it possible to set the date format on server level so that
> whenever a user runs a query it comes out in mm/dd/yyyy format? I know I
> can
> convert it to string then change the format but I don't want that option.
> Please help...
SQL Server has no control over how dates are displayed in your client
application. You need to configure that setting client-side, either in the
Windows Control Panel or in the client application or your development
environment.
SQL Server does have the LANGUAGE and DATEFORMAT settings but they purely
control how strings get converted to dates. Those settings do not control
how dates get displayed by client applications.
You could convert your dates to strings and return those string values to
the client as a way of controlling the format. I think that's a bad idea
however. For one thing it means you can't maniplulate the values as proper
dates any more. For another, IMO it is inconsiderate to force the user to
live with the format that you prefer.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||That's what I thought too. Just wanted to confirm. Thanks for your help.
"David Portas" wrote:

> "Bob" <Bob@.discussions.microsoft.com> wrote in message
> news:92CD54E6-1182-410B-A995-973737A7238D@.microsoft.com...
> SQL Server has no control over how dates are displayed in your client
> application. You need to configure that setting client-side, either in the
> Windows Control Panel or in the client application or your development
> environment.
> SQL Server does have the LANGUAGE and DATEFORMAT settings but they purely
> control how strings get converted to dates. Those settings do not control
> how dates get displayed by client applications.
> You could convert your dates to strings and return those string values to
> the client as a way of controlling the format. I think that's a bad idea
> however. For one thing it means you can't maniplulate the values as proper
> dates any more. For another, IMO it is inconsiderate to force the user to
> live with the format that you prefer.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>
>|||You can set the date format on a session level..
SET DATEFORMAT ydm
"Bob" <Bob@.discussions.microsoft.com> wrote in message
news:92CD54E6-1182-410B-A995-973737A7238D@.microsoft.com...
> If date format is set by default language and the default language is set
> to
> English and English has a mdy format, why would dates come out as ymd when
> queried? Is it possible to set the date format on server level so that
> whenever a user runs a query it comes out in mm/dd/yyyy format? I know I
> can
> convert it to string then change the format but I don't want that option.
> Please help...