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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SqlServerQuery

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-02-14 : 08:06:17
Vijay writes "sir,
I need a stored procedure/query which will accepts two dates say
from date and todate and one integr variable consists of two values either 5 or 6 means 5 dayweek or 6 day week... I need an output which should generated dayofweek for the day which is given from fromdate should dynamically generated weeks(depending on the integer variable value) till the todate comes..

For example

Input:

Integer Value: 5
5 day week means from monday to friday
6 dayweek means from monday to saturday

From date: 01/01/2005
To date: 31/01/2005

Output:

26/12/2004(Mon)- 31/12/2005(Fri)

3/1/2005(Mon)-07/01/2005(Fri)

10/1/2005(Mon)-14/01/2005(Fri)

17/1/2005(Mon)-21/01/2005(Fri)

24/01/2005(Mon)-28/01/2005(Fri)

31/01/2005(Mon)-04/02/2005(Fri)


Its urgent
expecting quick reply

Vijay"

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-02-14 : 13:51:23
Generate your sql into a variable the execute the sql with exec sp_executesql @sql
Example:
declare @sql as nvarchar(255)
set @sql = 'Select * from A Where datecolumn = ' + @inputvariable
exec sp_executesql @sql


You can do anything at www.zombo.com
Go to Top of Page
   

- Advertisement -