473,385 Members | 1,732 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,385 software developers and data experts.

Find every saturday and sunday in an interval of two dates

Hello. I've been working on a program for several days and I already have a few thousands of lines of codes written. But I'm facing with a big dilemma right now.

I'm kind of new to .NET, I'm working in Visual Studio 2013. I'm trying to find an easiest way to do the following:

I've got these objects:

DateTimePicker1
DateTimePicker2
ListBox1
Button1
Label1
Label2

In the DateTimePicker1, the user chooses the starting date. Let's say 1. january 2014.
In the DateTimePicker2, the user chooses the ending date. Let's say 1. july 2014.

Now, what I need the program to do is that when the user clicks on Button1, the following will show up in Label1 and Label2:

Label1 will show total days in a number in between the dates chosen in DateTimePicker 1 and 2.
label2 will show total days in a number in between the dates chosen in DateTimePicker 1 and 2 WITHOUT every sunday and saturday that occurs in between these two dates.

Also, every saturday's and sunday's dates in between the dates chosen in DateTimePicker 1 and 2 will be added to the ListBox1.

Is there anyone who could help me out? It's an important project to me and I still have about 40% of coding left, but this is stopping me. I can't continue working on my program until I get this solved. Thank you very much.
Jan 21 '14 #1
4 3529
Rabbit
12,516 Expert Mod 8TB
What have you tried so far and what errors are you getting?
Jan 21 '14 #2
Well I was trying lots of things. I know the code to count all of the days in between that interval:
Expand|Select|Wrap|Line Numbers
  1. Dim date1 As Date
  2. Dim date2 As Date
  3.  
  4. date1 = Convert.ToDateTime(DateTimePicker1.Value)
  5. date2 = Convert.ToDateTime(DateTimePicker2.Value)
  6. Dim diff As System.TimeSpan = date2 - date1
  7. Label1.Text = diff.Days + 1
And I was trying to use While, For and so on to somehow get all the dates of weekdays to be written in the ListBox1, but I can't figure out a proper way.

I found some code to count all of the fridays in a specified date range, but it didn't fit my case. Also, I couldn't get the dates to be written in ListBox1 as separate items. And due to it's format being DateTime, not Date even after I wrote Date only, it was writing the items as e.g. 25.4.2014; 17:32... but I don't want the time to be there. I believe it's due to the DateTimePicker's DateTime only format being available.
Jan 21 '14 #3
Rabbit
12,516 Expert Mod 8TB
Please show me the loop you tried.
Jan 21 '14 #4
I've got my question already answered. Thank you anyways :)

http://stackoverflow.com/questions/2...s-interval-net
Jan 21 '14 #5

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

Similar topics

11
by: Matt | last post by:
My ASP page allows the user select the date, and it will display the report during that week of that date. My question is when the program query database, I need to know the beginning date and...
11
by: Solomon Grundy | last post by:
Select trunc(sysdate,'MM') from dual of course gives me the first day of the month, may I ask what the query is to find the first saturday of the month?
2
by: Randy | last post by:
How do you do a find on a range of Dates in a Date field from the find dialog box?
3
by: Peter | last post by:
Has anyone written any code to find the date of every other Friday of the year? Is there an easy way of doing this?
1
by: mnoland | last post by:
I relay need some help I am looking to find every quarter between 2 dates here is an example of what i am trying to do data table client sbegin send 499 1-1-2000 6-1-2001...
2
by: sudhaMurugesan | last post by:
Hi, I need to find the previous date from a given date in java script. Is there any code for it.Can anyone tell me.Thanks in advance
3
by: pchaitanya | last post by:
I have selected some list of valid dates to a label. now i need to find first day among the given dates from label contrl i got dates from calender control by clicking for entire week.. ...
5
by: chopin | last post by:
My goal is to print a record every week between 2 dates. For example, let's say I have a beginning date and expiration date respectively of 9/25/08 and 9/25/09 The goal is to track the "active"...
1
by: Fred Boltz | last post by:
I am new to VB and seem help. I have 6 date fields, some of which might potentially be blank, and I need to compare these dates to find the lower of the 6 dates. If the field is blank, it should...
4
by: aaditya321 | last post by:
Hi Guys, Please let me know that how to find fourth Saturday of month.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.