Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To - Create Table Variable of dates MWF 2 years
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
How To - Create Table Variable of dates MWF 2 years
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01439385
Message ID:
01439385
Vues:
96
Hey Everyone

I was wondering if anyone had a quick set of SQL code to create a table variable and populate with two years of dates based off MWD or Tue/Thur/Sat

I will have start date and the string of valid dow. I only need to populate the Workdate and DOW in the table. Other fields will be blank until later processing. I'm not a SQL date wizard (or any wizard) so I didn't know if there is an easy way to figure all the dates for an insert into @TableOfDates.

Thanks for any help.
declare @StartDate varchar(10) = '12/16/2009'
declare @DowsOfWeek = '2,4,6'    -- MWF Example
declare @TableOfDates table
(
WorkDate varchar(10),
WorkDateNumber int,
SchedStart varchar(10),
SchedEnd   varchar(10),
VarianceFromPlanned int,
Booked bit
)
-- 2,4,6 is MWF
-- 3,5,7 is TTS
-------------------------------------------------------------------------------------------------------------------------------------------------------------
WorkDate    WorkDateNumber       SchedStart                SchedEnd          VarianceFromPlanned  Booked
--------------------------------------------------------------------------------------------------------------------------------------------------------------
12/16/2009        4  
121/8/2009        6
12/21/2009        2                           
12/23/2009        4
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform