We help IT Professionals succeed at work.

Show records entered between Monday to Friday

Bakersville
Bakersville asked
on
575 Views
Last Modified: 2008-04-24
Hi Everyone.

What I am about to explain I have no idea how to do.

I am trying to write a Time Recording reports for our help desk, to show time spent on certain days, weeks, month.

So to explain better.

I have a table

StaffID = INT
DateRecorded = DateTime
TimeSpent = DateTime


What I want to do is display Time Recorded depending on what they want to see.

i.e., Entered Today, Display All.  

However, the next few I do not know what to do.

Display all records this week. I want the sp to realise that today day is i.e., Thursday and only display all the records from Monday of that week to Thursday.

Display all records last week. I want to display all records for Monday to Friday from the previous week.

Display between Dates. So say between 1st to 14th June, This I can do, but do not know how to exclude Saturday's and Sunday's.

Display all record for the month. I want to display all records for the current month.

The last thing is to count the amount of days it is displaying...

Any help would be appreciated.

Many thanks
Baker
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
You might want to change IF .. ELSE... construct to give more logic for Monday, Sunday, Saturdays
>>>>Display all records last week. I want to display all records for Monday to Friday from the previous week
You could add these lines after IF else construct to get the start and end dates of the previous week.

SET @startdate = DATEADD(wk, -1, @startdate)
SET @enddate = DATEADD(dd, 4, @startdate)

Commented:
You are using Classic ASP i guess ?
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
Use this SQL statement:
SQL = "SELECT * FROM DateRecorded WHERE Year(Updated) = Year(Now()) AND Month(Updated) = Month(Now()) AND WeekDay(Updated) <> 1 AND WeekDay(Updated) <> 7"
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you everyone for all your help.

I have just this second got the whole lot to work.  Been a struggle but got there.

Everyone of you has helped me sort this out.  Helping to understand the proceedure, logic and i thank you once again.

Baker

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.