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
 Sql Data Format

Author  Topic 

ungureandavid
Starting Member

2 Posts

Posted - 2009-08-19 : 07:56:39
Hi

Just a simple question!
I'm working with sql server 2008, and i want to insert a date in format dd/MM/yyyy. Is there any trick to do that? I'm picking the date from a dateTimePicker (c#) in this format dd/MM/yyyy, but when i execute the query, the date format is in the yyyy-mm-dd:hh-mm-ss format.
I don't want to change my regional settings, because my program run's on many computers, and it is very difficulty to do that!

Hope you understood !

thanks

David

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-19 : 08:18:09
Let it store as it is. Formation should be done in the front end application. When sending dates to table format it as YYYYMMDD HH:MM:SS

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-08-19 : 08:18:31
That's how sql stores the date. If you want it to look different, you should format it in the front end. To format it in SQL use
select convert(varchar(10),getdate(),103)

But this is now a string, not a date.

Jim
Go to Top of Page

Mangal Pardeshi
Posting Yak Master

110 Posts

Posted - 2009-08-19 : 08:20:07
Hi David,

If you ask me it doesn't really matter. I guess you got yyyy-mm-dd:hh-mm-ss while executing the query in Management studio.

There is difference between how SQL Server store the data and how it displys it. How you want to see the date is a display issue and should be handle in the UI, and let SQL server store it in its default.

Mangal Pardeshi
http://mangalpardeshi.blogspot.com
Go to Top of Page

SQLRatankalwa
Starting Member

42 Posts

Posted - 2009-08-20 : 01:23:01
Please see Convert Method in Online help. There are various formats to retrieve the date or you can even convert them in the frontend ASP.NET.

Ratan Kalwa
SQL Server Professionals User Group

http://www.sspug.com
Go to Top of Page
   

- Advertisement -