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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query Date format

Author  Topic 

PanzerAttack
Yak Posting Veteran

71 Posts

Posted - 2011-07-07 : 09:05:50
Another simple one for you guys I'm sure:

SELECT dbo.T003_Trade_Reporting.ImportDate

This returns

2011-07-05 12:24:54.000
2011-07-05 12:45:02.000
2011-07-05 12:52:36.000

I just want to return 2011-07-05

How do I need to change my code. I can't figure out from what I've read.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-07-07 : 09:13:11
convert(varchar(10),dte,121)

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

PanzerAttack
Yak Posting Veteran

71 Posts

Posted - 2011-07-07 : 09:18:16
I'm really basic on this so:

SELECT dbo.T003_Trade_Reporting.convert(varchar(10),dte,121)
.ImportDate
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-07-07 : 09:33:00
SELECT convert(varchar(10),ImportDate,121)
from dbo.T003_Trade_Reporting

I don't have a good feeling about this

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

PanzerAttack
Yak Posting Veteran

71 Posts

Posted - 2011-07-07 : 09:55:30
Awesome, thank you
Go to Top of Page
   

- Advertisement -