-
Feb 21st, 2012, 07:50 AM
#1
Thread Starter
Lively Member
DB Puzzle
Any Date range within a week where the week start is monday and weekend is monday.
No Name FromDate Tilldate
1 ABCD 25-5-2010 25-5-2010
2 DSFA 22-6-2010 23-6-2010
3 WERQ 13-8-2010 19-8-2010
From above table, use T-SQL to split the above date range and
create a row for each date within the range like below
No Name Date
1 ABCD 25-5-2010
2 DSFA 22-6-2010
2 DSFA 23-6-2010
3 WERQ 13-8-2010
3 WERQ 14-8-2010
3 WERQ 15-8-2010
3 WERQ 16-8-2010
3 WERQ 17-8-2010
3 WERQ 18-8-2010
3 WERQ 19-8-2010
-
Feb 21st, 2012, 08:23 AM
#2
Re: DB Puzzle
Can you create a table with all dates in it? That is the obvious and easiest way to deal with this.
If you cannot do that then can you use a stored procedure to do this?
Is this MS SQL server?
-
Feb 21st, 2012, 08:27 AM
#3
Thread Starter
Lively Member
Re: DB Puzzle
Yes. It is MS SQL.. u just consider above is the table with date range.. Can u give me the solution for that?
-
Feb 21st, 2012, 08:30 AM
#4
Re: DB Puzzle
I would create another table with "all dates" in it and then join to that - simple join - but before I go to the effort of showing you a solution that involves another table.
Please answer my two other questions.
I did ask them - I would not have asked them if it didn't matter.
Why don't people answer questions put to them on the forum - it drives me totally insane!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|