Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DateTime dates store wrong

Author  Topic 

MirandaJ
Starting Member

35 Posts

Posted - 2007-12-14 : 16:06:16
I have a stored procedure to add a poeersons DOB to a table. The date is being stored as Dec 12 1980

Instead of as 12/12/1980

The table uses a datetime data type.
The data type of the date being passed into the stored procedure is also set to datetime. (@DOB datetime) Even though the value passed into the procedure is 12/12/1980 It saves the date as Dec 12 1980

What do I need to do to fix this?





Miranda

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-12-14 : 16:13:47
There is nothing to fix. You can't change how datetime stores data (data is not stored as Dec, that's just the default display), but you can change how you see the data. Change the format of the string via your front-end application or use CONVERT with the appropriate style in T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-12-14 : 16:18:38
Actuall, it is probably stored as: 0x0000737D00000000

But, I don't think that is the issue. It appears that you are having a display issue. You should only need to worry about that int he front end or, if you need to do soemthing special in SQL look up the CONVERT function.

Here is a helpful link about the SQL DATETIME data type: [url]http://www.sql-server-performance.com/articles/dev/datetime_datatype_p1.aspx[/url]
Go to Top of Page
   

- Advertisement -