Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 24th, 2007, 12:57 PM
Authorized User
 
Join Date: Oct 2006
Location: , , .
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:(

Reply With Quote
  #2 (permalink)  
Old January 24th, 2007, 02:13 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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^^
================================================== =========
Reply With Quote
  #3 (permalink)  
Old January 25th, 2007, 05:36 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
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???

Reply With Quote
  #4 (permalink)  
Old January 25th, 2007, 11:13 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The column is of type DateTime.

Reply With Quote
  #5 (permalink)  
Old January 30th, 2007, 04:00 PM
Authorized User
 
Join Date: Oct 2005
Location: , , .
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:31 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.