I am using SQL Server 2000 for an old system web site. I've just hit an issue that is going to cause me endless hassles down the road.
When I installed the server on my local system I took all the defaults but now any datetime data type is getting stored in mm/dd/yyyy
format.
Now this is not an issue for inserting data but when getting the data out and writing it to a page its in US format.
The site is going to be based in the UK on a UK server so I need my local development system to mirror that, and I also want to have to avoid using CONVERT on every field which is a datetime.
Tried changing the database collation a few times without success.
So my question was this:
Is it possible to change the format of the datetime so that inserting 23/01/1972 is stored as such and not 1/23/1972?
SERVER Properties:
- Default language: English (United States)
- Collation: SQL_Latin1_General_Cp1_CI_AS
Database Properties
- Collation: SQL_Latin1_General_CP1_CI_AS
Specifically as as example
CREATE TABLE [dbo].[lbg_app_section1](
[id_app_section1] [int] IDENTITY(1,1) NOT NULL,
[refid_applications] [int] NOT NULL,
[dateofbirth] [datetime] NULL,
[gender] [nvarchar](50) NULL,
[ninumber] [nvarchar](15) NULL,
[address_hsno] [nvarchar](60) NULL,
[address_twncty] [nvarchar](60) NULL,
[address_cnty] [nvarchar](60) NULL,
[address_postcode] [nvarchar](15) NULL,
[address_country] [nvarchar](30) NULL,
[dt_section1_modified] [datetime] NULL
) ON [PRIMARY]
Best Answer
As stated in the comments, dates are not stored as "dates". They are actually stored as numbers. So there is no need to worry about that side of things. You can change the default output though by changing your language setting.
This is the setting for
British English
. You can see all of them displayed in thesyslanguages
system view.syslanguages
also contains the default date format. In the case ofBritish English
it isdmy
.American English
ismdy
.