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.
Author |
Topic |
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2007-09-28 : 09:26:27
|
Hi All,I know this question sound childish. But I am in middle of something, and cannot find the answere in books online.Q)How to get the date part of a following format datetime.2005-12-28 00:00:00I want to return 2005-12-28 only in this example.What should I use DATEPART() or convert() & how?Please help. |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-09-28 : 09:28:57
|
[code]select Left(convert(varchar(10), getdate(), 120), 10)[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2007-09-28 : 09:30:45
|
zeeshan, the example you gave already is truncated to a whole date value. If you are talking about only displaying the date portion, that logic belongs in your presentation layer. Not the database.e4 d5 xd5 Nf6 |
 |
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2007-09-28 : 09:35:47
|
harsh_athalye,Now I remember. Thanks for the help. blindman,I am dealing with Database only. Thanks for the feedback. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-28 : 09:36:25
|
quote: Originally posted by zeeshan13 Hi All,I know this question sound childish. But I am in middle of something, and cannot find the answere in books online.Q)How to get the date part of a following format datetime.2005-12-28 00:00:00I want to return 2005-12-28 only in this example.What should I use DATEPART() or convert() & how?Please help.
As said, do the formation at front end if you want to show formatted dates thereMadhivananFailing to plan is Planning to fail |
 |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2007-09-28 : 12:19:42
|
quote: Originally posted by zeeshan13 blindman,I am dealing with Database only. Thanks for the feedback.
Then that is a problem, because a database is not an application.e4 d5 xd5 Nf6 |
 |
|
Kristen
Test
22859 Posts |
|
|
|
|
|
|