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 |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2005-09-08 : 22:48:54
|
| When I ran this query select getdate().It gave me this value :-2005-09-08 19:45:54.280How can I convert the above date to something like shown below2005-09-08 00:00:00.000 |
|
|
ryanston
Microsoft SQL Server Product Team
89 Posts |
Posted - 2005-09-08 : 23:50:28
|
| Are you just trying to get the date from the datetime? Take a look at DATEPART if so. Otherwise, can you be a bit more detailed in what you're trying to do?Thanks,----------------------Ryan StonecipherDeveloper, Microsoft SQL Server Storage Engine, DBCC(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2005-09-09 : 00:59:07
|
| I want the value to be 2005-09-08 00:00:00.000 so that i can the events that happend for the day at any point of time by checking the date > 2005-09-08 00:00:00.000 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-09 : 01:00:22
|
| SELECT DateAdd(d, DateDiff(d, 0, getdate()), 0)MadhivananFailing to plan is Planning to fail |
 |
|
|
venkatsrv
Starting Member
2 Posts |
Posted - 2005-09-09 : 02:06:34
|
| SELECT cast(convert(varchar,getdate(),101) as datetime) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-09 : 02:15:09
|
Venkat, yours use two conversions whereas mine use no conversionsAlthough it is alternate solution, avoid using Conversions MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-09-09 : 04:24:19
|
| "SELECT cast(convert(varchar,getdate(),101) as datetime)"Only works on a server configured for USA date formatI posted a comparison of performance a while back - if you are interested! The CONVERT/CAST method is abou 3 - 5 times slower than the one with no conversions.http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=38940Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-09 : 04:38:32
|
Thats good point Kris MadhivananFailing to plan is Planning to fail |
 |
|
|
VladRUS.ca
Starting Member
23 Posts |
Posted - 2005-09-09 : 10:27:25
|
One more variant:set dateformat ymdselect {fn current_date()} |
 |
|
|
|
|
|
|
|