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 |
|
DavidChel
Constraint Violating Yak Guru
474 Posts |
Posted - 2008-04-22 : 15:13:45
|
| I'm trying to find the current period (fnnumber) that we are in. fdstart is the start of the periods. select fnnumber from glrule wherefdstart=(select max(fdstart) from glruleWHERE fdstart < getdate())Is there a better way to do this? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-04-22 : 16:22:40
|
| maybe:select top 1 fnnumberfrom glruleorder by fdstart desc_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2008-04-23 : 05:07:23
|
| Quaternary or Anthropocene, I'd say.Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2008-04-23 : 05:17:32
|
You might need to add a where clause to spirit1's suggestion...select top 1 fnnumber from glrule where fdstart < getdate() order by fdstart desc And if fdstart is not necessarily unique, you might want a 'with ties' after the 'top 1'.Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
DavidChel
Constraint Violating Yak Guru
474 Posts |
Posted - 2008-04-23 : 09:09:16
|
quote: Originally posted by RyanRandall You might need to add a where clause to spirit1's suggestion...select top 1 fnnumber from glrule where fdstart < getdate() order by fdstart desc And if fdstart is not necessarily unique, you might want a 'with ties' after the 'top 1'.Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part.
Thanks for your help. That works and I'll use it. |
 |
|
|
|
|
|