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 |
|
zubair
Yak Posting Veteran
67 Posts |
Posted - 2009-10-09 : 04:46:35
|
| Hi i have a query like so:select last_action_timefrom clicky_recent_visitorsthis generates data like following:2009-10-09 09:29:00.0002009-10-09 09:28:00.0002009-10-09 09:25:00.0002009-10-09 09:23:00.0002009-10-09 09:22:00.000What i would like is to create another column in the clicky_recent_visitors table called visitor_active which will be a bit field. Now I want this field to be a calculated field i.e a formula. I would like this formula to set the value in this field to 1 if the last_action_time is less than 30 mins from the current time. And set the value in this field to 0 if the last_action_time is greater than 30 mins from the current time.I haven't done anything like this before. Can anyone please help me?ThanksZubair |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-10-09 : 04:58:17
|
| update my_table set visitor_active =case when datediff(mi,last_action_time,getdate()) <30 then '1' else '0' endSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
zubair
Yak Posting Veteran
67 Posts |
Posted - 2009-10-09 : 05:11:10
|
| thx senthil |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-10-09 : 05:23:00
|
quote: Originally posted by zubair thx senthil
Welcome Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
|
|
|