| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-12-27 : 11:05:27
|
| Santosh writes "I have a table two field startdate and enddate. I want to get all the dates between startdate and enddate as rows in an SQL query.eg startdate = 12/12/2001enddate = 16/12/2001i want the following result asdate12/12/200113/12/200114/12/200115/12/200116/12/2001Please help me out ASAP" |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2001-12-27 : 11:14:58
|
| select * from tablename where date between @startdate and @enddateorselect * from tablenamewhere (date >=@startdate and date<=@enddate)Mike "A program is a device used to convert data into error messages." |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
|
|
daKarateKid
Starting Member
15 Posts |
Posted - 2001-12-27 : 12:09:23
|
| I think the easiest way is to create a temp table to hold each date that you wish to display, then implement a loop that inserts the startdate into the table, then increment the startdate, and keep going as long as the startdate <= enddate. You could also implement this as a union, but you would have to use dynamic sql if you didn't know how many dates there were between the startdate and the enddate.Does that help?dKK |
 |
|
|
Rafiq
Starting Member
25 Posts |
Posted - 2002-01-05 : 02:23:04
|
| Hi,It will work fine. try it.select * from tablenamewhere (date >=@startdate and date<=@enddate)Order by StartDateRafiq------------------------------------If you think, you can do anything... |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-05 : 02:57:39
|
DaKarateKid! R u fascinated by Unions or what?. i saw it here toohttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=11747 Hope i dont get a Kick! with your Expertise in Karate Ajarn teach me some self Defence techniques .----------------------------Anything that Doesn't Kills you Makes you Stronger |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-01-05 : 21:49:24
|
quote: Ajarn teach me some self Defence techniques .
Okay Nazim. Lesson #1: Learn not to provoke your opponent or teammate.--------------------------------------------------------------1000 Posts, Here I come! I wonder what my new title will be... |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-01-05 : 22:14:02
|
| Lesson #2 : Duck!Damian |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-01-05 : 22:31:25
|
heh heh... that's good Merkin. Followed shortly thereafter by RUN!--------------------------------------------------------------1000 Posts, Here I come! I wonder what my new title will be...Edited by - AjarnMark on 01/05/2002 22:32:00 |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-05 : 23:37:34
|
Am Running to the Mark .----------------------------Anything that Doesn't Kills you Makes you Stronger |
 |
|
|
|