Wednesday, March 7, 2012

Date format

Hello
I have a table that one of its column is in dateTime
format.
My date format in the pc is dd/mm/yyyy (in the Regional
Options)
In the Query Analyzer I run "SET DATEFORMAT DMY" but when
I try to enter data as "21/3/2004 12:00:00" I get error.
when I try to enter data as "3/21/2004 12:00:00" I get no
error and the data is entered into the table.
I need to work only with "dd/mm/yyyy hh:mi:ss" format.
How can I config/set my SQL Server to work
with "dd/mm/yyyy hh:mi:ss" format ?
Thank you very much!!!
Hi,
This worked fine for me, Please check.
create table date_chk(x datetime)
go
set dateformat 'dmy'
insert into date_chk values('21/3/2004 12:00:00')
Thanks
Hari
MCDBA
"MR.T" <anonymous@.discussions.microsoft.com> wrote in message
news:1562e01c41af3$070994a0$a601280a@.phx.gbl...
> Hello
> I have a table that one of its column is in dateTime
> format.
> My date format in the pc is dd/mm/yyyy (in the Regional
> Options)
> In the Query Analyzer I run "SET DATEFORMAT DMY" but when
> I try to enter data as "21/3/2004 12:00:00" I get error.
> when I try to enter data as "3/21/2004 12:00:00" I get no
> error and the data is entered into the table.
> I need to work only with "dd/mm/yyyy hh:mi:ss" format.
> How can I config/set my SQL Server to work
> with "dd/mm/yyyy hh:mi:ss" format ?
> Thank you very much!!!
>
|||This is a prob to do with US/ UK date formats in SQL... you need to use the "SET DATEFORMAT DMY" in SQL where it inserts the date into the DB, for example...
var sql_statement = "SET DATEFORMAT DMY \n UPDATE Mobile..."
\n refers to a line break, for javascript. If you use VBscript, replace with appropriate command vbctrlf or something (not sure exact).
This should be done on all SQL statements that are entering dates.
Hope it helps,
Chris
************************************************** ********************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

No comments:

Post a Comment