Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2007, 12:57 PM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatting Dates

I'm having a problem with my dates in sql server. Right how the dates in the database have several different formats such as...
12/25/2004 00:00:00
1/1/2004
2/2/86
1122003
What I am trying to do is format the complete column permanently so that whenever i run a query for the dates, the correct data will pop up. I've tried using the convert function, but all that does is convert one date at that particular time. I want to be able to convert all the dates in that particular column permanently to look like mm/dd/yyyy. Please Help:(

 
Old January 24th, 2007, 02:13 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Is the column of type DateTime? You could do: SELECT convert(varchar(10), column, 101) as column From table which will select the entire column and format them all at once.

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
 
Old January 25th, 2007, 05:36 AM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jxvip
Default

      I have this problem too..... help me???

 
Old January 25th, 2007, 11:13 AM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The column is of type DateTime.

 
Old January 30th, 2007, 04:00 PM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Based on your sample data, I don't think that the column is of DateTime data type. If it is, then you don't have to worry about anything because internally, SQL Server stores DateTime data types as 2 4-byte integers. For other questions about datetime data types in SQL Server, you can refer to the following link:

http://www.sql-server-helper.com/faq/dates-p01.aspx

SQL Server Helper
How well do you know SQL? Find out with the free test assessment from SQL Server Helper!!!
http://www.sql-server-helper.com/free-test/default.aspx

Got a SQL Server Question? Ask us here: http://www.sql-server-helper.com/forums/default.asp





Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting strings / dates clandestine XML 3 June 22nd, 2005 09:52 AM
Formatting For Between Dates hcweb Classic ASP Basics 7 February 8th, 2005 02:29 AM
formatting dates treasacrowe Classic ASP Basics 3 October 20th, 2004 06:52 PM
Formatting dates in XSL francislang XSLT 4 September 3rd, 2004 08:17 AM
Formatting Dates Louisa VB.NET 2002/2003 Basics 3 March 16th, 2004 05:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.