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 |
|
honeytjames
Starting Member
3 Posts |
Posted - 2008-10-19 : 21:42:43
|
| I have a column of datetime type. How do i insert a value less than getdate()? |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-10-19 : 22:05:09
|
| insert into yourtable (todaysdate) select getdate() -1 -- gives you yersterday's dateOr add the getdate() - 1 to the default values |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-10-19 : 22:23:34
|
| Also bear in mind, you can get different hours based on fractions of 1/24 (Which is 0.04166666666 and will give you 1 hour)So to get the time, an hour back or an hour ahead you can useselect getdate() select getdate() +0.04166666666666666666666select getdate() -0.04166666666666666666666 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-19 : 23:43:03
|
| or use DATEADD function. use negative number to add likeDATEADD(dd,-3,GETDATE())... |
 |
|
|
|
|
|