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
 General SQL Server Forums
 New to SQL Server Programming
 Access Calender Creation Problem

Author  Topic 

mdixon44
Starting Member

26 Posts

Posted - 2009-01-13 : 13:12:39
Create a calendar showing all the weekends (Saturday and Sunday) for a two month period after your next birthday. List these date in a format such as june 5, 2025. In a second column, put the abbreviation of the day, Sat or Sun. Put one blank line between the weeks.

Following the steps to successfully complete this task

Step 1 create the table

create table WkendCal
(start_date datetime,
end_date datetime);

insert into WkendCal
values (#01-MAR-2009# , #01-JUN-2009#);

Step 2 Create the table containing all the consecutive days

select n,
cdate(start_date + n) as date_1
into WkendCal
from number_0_to_99,
where start_date + n < end_date;

Now step 3 is the one that I can not figure out. How do I delete all of the days and just leave Saturday and Sunday. If anyone can assist me on this one, I would appreciate it.


jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-01-13 : 14:59:31
Not sure of the exact Access syntax, this is a MS SQL Server forum, but rather than delete the recs, just
select the ones you want
SELECT *
From WkendCal
WHERE Weekday(yourDate) = 1 or Weekday(yourDate) = 7

Jim
Go to Top of Page
   

- Advertisement -