Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
I have a table for working days and general holidays. I filled general holidays by this year government holidays. now i want to fill working days tables based on general holidays for full year(for example this year).For that i have decided to fill working day by filling day by day (mean when i fill today with date in working day table,tommorrow will be automatically added to the table from after midnight(12.00AM)).This date should be compare with general holidays and then fill with working table.if both day matching then that day not to fill with working days table. please give me an idea.i will do it,if you are giving some kints about this method.


working day table contain fields.1.wid,2.date,3.day,4.wdaytype(full /half )
general holiday table contain. 1.gid2.date,3.day,4.reason.






Thank you advance
Posted
Updated 24-Aug-12 21:44pm
v3
Comments
Wendelius 25-Aug-12 3:04am    
Please explain more what you're trying to do. An example would also clarify the question
OriginalGriff 25-Aug-12 3:17am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

if i coorectly understands your question then..
you want to insert date in to table at midnight..

then you can use sql agent job
 
Share this answer
 
v2
Not sure if I still interpreted this correctly, but...

First if you're interested only in dates, you can use date data type which contains no time information, see http://msdn.microsoft.com/en-us/library/ms186724.aspx[^].

Now to generate the data into the table, you can create a small T-SQL block where you loop through the desired dates. Something like
SQL
DECLARE @startDate date;
DECLARE @endDate date;
BEGIN
   SET @startDate = GETDATE();
   SET @endDate = GETDATE() + 365;
   WHILE (@startDate <= @endDate) BEGIN
      INSERT INTO YourTable (DateColumn) VALUES (@startDate);
      SET @startDate = DATEADD(day, 1, @startDate);
   END;
END;

You should modify the block to check for the holiday.

Another possibility is that you actually don't store the working day at all, just the holidays. Now to get the working dates between a date range, you could use a table valued function which can be used in a query like a table. Have a look at this article: Using Table-Valued Functions in SQL Server[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900