Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7778713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:28:00+00:00 2026-06-01T18:28:00+00:00

I am stuck at a point where I have to exclude the weekends tickets

  • 0

I am stuck at a point where I have to exclude the weekends tickets and need to count the rest tickets(just weekdays).

Let’s suppose:

tickets               dates
-----------           ----------
123                   04/05/2012
231                   04/06/2012
111                   04/07/2012
112                   04/08/2012 
113                   04/09/2012

So, In the above table we have a data for 5 days including weekday and weekend.

I just need weekday data not the weekend in my final table like this:

tickets               dates 
-----------           ----------
123                   04/05/2012
231                   04/06/2012
113                   04/09/2012
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:28:01+00:00Added an answer on June 1, 2026 at 6:28 pm

    Don’t bother with datefirst. It can cause problems

    select * from @t 
    where datediff(d, 0, dates)%7 < 5
    

    EDIT:
    Datefirst is different from database to database. So you need to set datefirst before using ‘DatePart(dw,dates)’
    of the week. That means that every time you run the script you should call that datefirst. In case you decide to put it in a function you are screwed because you can’t use it inside that function. So every time you call that function you rely on people remembering that datefirst part.

    My solution does not rely on the individual setting of the database.

    What it does is this:

    calculate the days between 0 which represent 1900-01-01(a monday) and dates.

    modulus 7 of that is a daynumber between 0(monday) and 6(sunday) so less than 5 is a weekday.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started to practice c++ and I am stuck at one point.
I am stuck with the rotation I have set the movieclip's registration point to
I am doing an assignment and stuck at this point: I have a class
I have been stuck at this point for a long time and even after
I am writing a java application; but stuck on this point. Basically I have
I'm currently in a stagnant (stuck) point here. First of all, let me clearly
I am currently stuck at this point where I need to set an xsd
A logical stuck point. I am building a simple ACL, and I am just
I am stuck at this point. Scenario is like that - I have already
I' m at this point stuck : I want to have a scrollview +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.