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 |
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-04-16 : 13:31:48
|
| Hi guys,I dont know whether this question sounds silly.I came up with a situation where I need to know what was the time 30 minutes before the current time.Is there any straightforward way to get it..?Regards |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-04-16 : 13:35:33
|
| select dateadd(n, -30, getdate())_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-04-16 : 13:40:36
|
quote: Originally posted by spirit1 select dateadd(n, -30, getdate())_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com
That was really a quick answer.Thanks.Can I know why select datediff(n,-30, getdate()) this does not work. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-04-16 : 13:43:48
|
| because datediff returns a difference between 2 datetimes in the unit you provide as the first parameter_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-16 : 13:45:30
|
| the second argument of datediff should be a datetime value. Look for syntax and explanation in BOL. It actually provides the diffrence in units specified by first argument between the secong argument date value and third argument date value. |
 |
|
|
|
|
|