Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Update column Parse out Time?

Posted on 2007-10-01
6
Medium Priority
?
167 Views
Last Modified: 2010-03-19
I 've a datetime column with (550 rows) of good dates but useless times (6/29/1906 12:00:00 AM);

Q. How do I delete the time (12:00:00 AM) and leave the dates?
0
Comment
Question by:kvnsdr
  • 4
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 19991174
the datetime datatypes stored both date and Time parts, so you can't eliminate and store the dates on these columns. as an alternative, you can convert the dates to varchar and store it on a varchar(10)  / varchar(8) column, but this is not advisable if you need to perform  lot of date operations
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 19991189
in case it is just for displaying purpose , use a select statement similar to this

SELECT CONVERT(varchar(10) , getdate(),120 )
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 19991256

  Okay, good point 'aneeshattingal' on the datetime type.

  How does this code not have the column name in it?

  SELECT CONVERT(varchar(10) , getdate(),120 )
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1000 total points
ID: 19991308
replace the 'GetDate() ' with the column name

SELECT CONVERT(varchar(10) , urDateColumnName, 120 ) as urNewColumnName
from urTable
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 19991395
Interesting, this also seems to work.

SELECT CONVERT(varchar(10),getdate(),101) MyDate from Table1
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 19991411
that will return only today's date  (Getdate() gives you current Date along with time   )
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question