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-12-20 : 13:36:41
|
| How can I convert a datetime field into just date in my select statement.That is in my SELECT I want to convert 2007-08-18 00:00:00 to 2007-08-18.How can I do that?Please help.Zee |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-12-20 : 13:38:13
|
| You can use the CONVERT functoin with the appropriate style. For instance, SELECT CONVERT(varchar(10), GETDATE(), 101).But you should be handling this at the presentation layer instead.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2007-12-20 : 13:41:07
|
| Thanks tkizer.But its is converting it as 08/18/2007. Wheras I want it to be as 2007-08-18.Any idea? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-20 : 13:42:51
|
Yes.Read Books Online for other values of Style for the CONVERT function.You have 118 posts. You should know better by now. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-12-20 : 13:47:12
|
| I used style 101 in my example. Check out what other styles there are by checking out the CONVERT function in BOL. We aren't here to hold your hand with your issues but rather to provide the tools needed to solve your problem, which is what we've done here.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|