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
 Help removing time from a date

Author  Topic 

CRWilliams
Starting Member

2 Posts

Posted - 2012-07-13 : 17:56:57
My query looks like this

SELECT ErrorsTable.DateOfError
FROM ErrorsTable
WHERE (((ErrorsTable.ResolutionFlag)=False) AND ((BIPSErrors.User)="CRWilliams"));

Which returns a single column of dates like this:
7/11/2012 8:07:16 AM
7/11/2012 2:58:42 PM
7/13/2012 1:13:16 PM
7/13/2012 1:13:24 PM

However, I would like the column to look like this:
7/11/2012
7/11/2012
7/13/2012
7/13/2012

I can't figure out how to remove the time from my dates. Thanks in advance to anyone who can help.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-07-13 : 17:57:55
You can use the CONVERT function with the appropriate style, I believe 101.

But this is not a problem for SQL. You should be doing this formatting in your application. Let SQL return raw data. Format it in your application code.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

CRWilliams
Starting Member

2 Posts

Posted - 2012-07-13 : 18:05:16
quote:
Originally posted by tkizer

You can use the CONVERT function with the appropriate style, I believe 101.

But this is not a problem for SQL. You should be doing this formatting in your application. Let SQL return raw data. Format it in your application code.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



I forgot to include one other piece of information in my original post. I also want to get distinct values. So I actually need the list to look like

7/11/2012
7/13/2012

I'm just using these numbers to populate a listbox and I think It would make my code a lot cleaner to not have to filter the results from the query.

How would I use the convert function?

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-13 : 23:26:47
why not look it up in books online and try it for yourself

http://msdn.microsoft.com/en-us/library/ms187928.aspx

for getting distinct values apply distinct

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -