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 |
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2011-02-04 : 07:18:37
|
| Hello there.i want to create a between clause for a date. BUT. I have three variables.One for Day, one for Month and One for year.Is there a way i can concatinate them into a between clause.for eg date between 'variable1-variable2-variable3 ANDvariable1-variable2-variable3 'MCTS / MCITP certified |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-02-04 : 07:24:21
|
| what are there data types?JimEveryday I learn something that somebody else already knew |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2011-02-04 : 07:28:27
|
Assuming they are integers and a 4 digit yearCONVERT(varchar(8), (@YEAR*10000) + (@MO*100)+(@DAY))you would be better to do DATE>= CONVERT(varchar(8), (@YEAR*10000) + (@MO*100)+(@DAY)) and DATE <= CONVERT(varchar(8), (@YEAR*10000) + (@MO*100)+(@DAY)) Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-04 : 09:18:42
|
| ordatecol>=dateadd(day,@day,dateadd(month,@month-1,dateadd(year,@year-1900,0)))anddatecol<dateadd(day,@day,dateadd(month,@month-1,dateadd(year,@year-1900,0)))+1MadhivananFailing to plan is Planning to fail |
 |
|
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2011-02-04 : 10:03:28
|
| how do i select the the first day of the year, but only the day not the whole date. eg 01 |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2011-02-04 : 12:04:31
|
If it is already a variable, just pass a 1 as the value... Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
|
|
|
|
|