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
 How to tell DB not to store datetimes in 24 Hr. fo

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-04-11 : 14:10:19
There's gotta be a way to tell a DB not to store datetime fields as 24 hour format but rather standard time notation.

So, I don't want this: 2007-04-11 02:01:31.000

I do want this: 2007-04-11 02:01:31 AM

This has to be possible but I can't find it.

Thanks!



--PhB

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-11 : 14:14:02
Why does it matter how the database stores the data? You can't specify this with a datetime date type. Just retrieve your data, then have your presentation layer (your application) change the format to what you want.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2007-04-11 : 14:21:40
look at the CONVERT function. it can be used to help you format datetime information in your SELECT statement.



-ec

Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-04-11 : 14:30:56
Well, I was just thinking, why should I worry about converting and the like when the DB can do it for me. But i datatime can't do it then that's that.

Thanks!

--PhB
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-11 : 15:56:59
quote:
Originally posted by eyechart

look at the CONVERT function. it can be used to help you format datetime information in your SELECT statement.

-ec




If you do this, you are no longer returning DateTimes, you are just returning VARCHARs, which will not sort or compare correctly as a date, and which you cannot use date functions and also your clients will not interpret as a date, rather as a string. Always format your data at the client, never in SQL Server.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -