473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Calculating the Weekend Days(Saturaday,Sunday)

Manikgisl
HI,

I have two different dates

26-12-2008 to 26-01-2009
these are the two dates ..

i want calculate number of saturday and sundays in between two dates



Pls help me

With Regards,

Mani
Mar 12 '09 #1
4 1993
tlhintoq
3,525 Expert 2GB
What have you tried so far?
Mar 12 '09 #2
tlhintoq
3,525 Expert 2GB
Have a counter for Saturday and another counter for Sunday.
Loop through all the days and if that day is one or the other, add to the appropriate counter.

Expand|Select|Wrap|Line Numbers
  1.                 DateTime DateInQuestion = DateTime.Now;
  2.                 if (DateInQuestion.DayOfWeek == DayOfWeek.Saturday)
  3.                 {
  4.                     // Increment Saturday counter
  5.                 }
  6.                 else if (DateInQuestion.DayOfWeek == DayOfWeek.Sunday)
  7.                {
  8.                    // Increment Sunday counter
  9.                 }
  10.  
Mar 12 '09 #3
vekipeki
229 Expert 100+
Maybe you could get it from the total number of days between those two dates?

Expand|Select|Wrap|Line Numbers
  1. double numberOfDaysElapsed = (date2 - date1).TotalDays;
Note that you need to take into account which week days your dates actually are (e.g. Monday to Wednesday is not the same as Friday to Sunday).
Mar 12 '09 #4
tlhintoq
3,525 Expert 2GB
Exactly. There are several ways to do this. Counters looping through, or formula based on the days of the week for the starting date etc. Which is why I asked what the OP had tried so far... If he actually tried anything at all before asking for help.
Mar 12 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Eric Linders | last post by:
Hello, Today is Thursday, August 18, 2004. I would like to have a variable that stores the date this coming Sunday (even if today happened to be Sunday) in YYY-MM-DD format. I also need a...
38
by: | last post by:
I have a script... ----- <SCRIPT language="JavaScript" type="text/javascript"> <!-- function makeArray() { for (i = 0; i<makeArray.arguments.length; i++) this = makeArray.arguments; } ...
7
by: AdityaK | last post by:
Is there a way to find Weekend date for a given date using a DB2 query? I see that there are scalar functions such as DAY, DAYOFMONTH, DAYOFWEEK,etc are available...but couldn't find one to get a...
6
by: Zee | last post by:
I need help using a query to calculate or subtract values in a row tblCalRows RowID RowValue 1 A 2 B 3 C 4.... D
1
by: rock72 | last post by:
I am developing a application using this fields as required by the company. 1. Date Login 2. Time IN 3. Time OUT My question is how to produce the number of days with 1 entry of Date is...
1
by: rock72 | last post by:
Hello Everyone, Can you tell me how to produce a query that when Login Date (entry) is Sunday. First, check if the Sunday Date occur on 7th day of his duty. Example 1: Login Date no. of...
0
by: Trent Nelson | last post by:
Just a friendly reminder that this weekend is the Python sprint weekend! Look forward to seeing everyone on #python-dev irc.freenode.net over the course of the weekend! Trent. On 16 Apr,...
8
by: =?Utf-8?B?QWw=?= | last post by:
I am working in vb2005. how can I calculate business days (not including holidays and weekends) between 2 dates? thanks Al
8
Manikgisl
by: Manikgisl | last post by:
HI, I have two different dates 26-12-2008 to 26-01-2009 these are the two dates .. i want calculate number of saturday and sundays in between two date
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.