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
 General SQL Server Forums
 New to SQL Server Programming
 Help removing time from a date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

CRWilliams
Starting Member

2 Posts

Posted - 07/13/2012 :  17:56:57  Show Profile  Reply with Quote
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

USA
35007 Posts

Posted - 07/13/2012 :  17:57:55  Show Profile  Visit tkizer's Homepage  Reply with Quote
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 - 07/13/2012 :  18:05:16  Show Profile  Reply with Quote
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

India
47040 Posts

Posted - 07/13/2012 :  23:26:47  Show Profile  Reply with Quote
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
  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.09 seconds. Powered By: Snitz Forums 2000