August 23, 2006 at 1:34 am
Is it possible to set DateTime format (e.g MM-DD-YYYY) in Date/Time data type for specific column?
regards,
August 23, 2006 at 1:42 am
Datetimes are not stored in any format in a table. They're stored in a numeric format.
If you want to display a date in a specific format, then you'll need to convert to string either in the query, or in your presentation layer.
Look up CONVERT in books Online. It has all sorts of date formats available.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 23, 2006 at 2:31 am
MS SQL Date Time format is depend on the date time format in the computer. But, i don't want to use the date time format of the computer. So, how can i do?
August 23, 2006 at 2:43 am
Hi,
As GilaMonster indicated, forget about how dates are stored in SQL Server (it doesn't really matter). All you have to worry about is how you present it.
Look at the CONVERT function in books online.
For example:
select
convert(varchar(10),getdate(),110) --the style 110 corresponds to mm-dd-yyyy
August 23, 2006 at 2:46 am
Because i will use .net and the parameter to insert the data. when i insert the data, i have to provide the date time format. Otherwise, i will get error. So, that's why i ask the date time format.
J
August 23, 2006 at 2:57 am
In that case you've got to make sure that it is in the correct format when you pass it through from .net.
So you have to do this in your .net code.
Check out the String.Format() method or the ToString() method.
Here's an msdn link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandarddatetimeformatstrings.asp
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply