SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Setting SQL server default date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

android.sm
Starting Member

36 Posts

Posted - 05/14/2011 :  16:31:14  Show Profile  Reply with Quote
How do I set the current date field in sql server 2008 express to something like this:

14 May 2011 10:00pm

At the moment I use GETDATE() - but would like to format it to the above.

SELECT CONVERT(VARCHAR(20), GETDATE(), 100) returns me May 14 2011 9:22PM - which is good enough for me. But how do I apply that statement in the table designer field?

Thanks All!

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 05/14/2011 :  16:40:15  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
Never, never, never store a date in a varchar column. Store as a datetime and do your formatting in the queries of front end.

You're setting yourself up for massive pains putting a date into a varchar.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

android.sm
Starting Member

36 Posts

Posted - 05/14/2011 :  19:34:44  Show Profile  Reply with Quote
Thanks for getting back.

The front end has no date capturing hence why I'm setting the default value the getdate() to capture current date the moment a record is created - and the column in the table is datetime.
Go to Top of Page

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 05/15/2011 :  04:24:13  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
Cool, then you're all set. Just put the default as getdate() and do the formatting when you query the data. A datetime column has no defined format (format is purely and only a string concept)

--
Gail Shaw
SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000