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

Crazy trouble on date

Hi everyone

i got a problem on date, it is...

1, i get the date from calendar component

2, compare today and selected date is equal (compare method)

3 count the number of day between this 2 date

but i cannot find any method to count the number of day between this 2 date

just like...2006/4/5 - 2006/4/1....i will get the result 4

anyone know how to do subtrust the date???

thx a lot
Apr 22 '06 #1
1 1272
Hi Budd,
1, i get the date from calendar component Use the SelectedDate property, or the SelectedDates property, depending upon
which SelectionMode you're using. This returns a DateTime.
2, compare today and selected date is equal (compare method) Assuming that you only need to compare to the day, use the DateTime.Subtract
method. The DateTime.Subtract method is an instance method of the DateTime
structure, and takes another DateTime as an argument. It returns a TimeSpan,
indicating the difference between the 2 Dates. The TotalDays member of the
TimeSpan is a double which indicates the total number of days in the
TimeSpan. Since you only want to compare to the Day, you need to eliminate
fractional days from the value. This is easily done by casting the value as
a long.

If the result is negative, the second date is greater than the date
subtracting it, by that many days. If you just need to know if the dates are
the same day, all you need to do is compare the long integer result to 0.
3 count the number of day between this 2 date Same deal as number 2. If you only need to know the number of days, use
Math.Abs to get rid of any negativity.
anyone know how to do subtrust the date??? Nah, sorry, don't know that one.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Budd" <bu**@add.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl... Hi everyone

i got a problem on date, it is...

1, i get the date from calendar component

2, compare today and selected date is equal (compare method)

3 count the number of day between this 2 date

but i cannot find any method to count the number of day between this 2
date

just like...2006/4/5 - 2006/4/1....i will get the result 4

anyone know how to do subtrust the date???

thx a lot

Apr 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
38
by: Kai Jaeger | last post by:
I am playing with setting font sizes in CSS using em as unit of measurement. All seems to be fine. Even Netscape Navigator shows the characters very similar to IE, what is not the kind if px is...
8
by: Eric A. Johnson | last post by:
I am using scanf (from stdio.h) and having trouble inputting a date. I want the user to be able to input a date in the format mm/dd/yyyy. I use the following: printf ("Please enter your first...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
1
by: Merlin | last post by:
Hi Again Group, Sorry to trouble you all again but i`ve been looking at this problem for 2 weeks now and just don`t seem to be able to grasp how to create a relationship in VB.NET with ADO.NET....
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
0
by: Aws | last post by:
My crazy GridView !! I am using Visual Studio 2005, I have a problem with my GridView. I have one access .mdb table and when I update a record on the table EVERYTHING is perfect. I made a Web...
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
2
by: totomalas | last post by:
I have tried this code so many times, and it is frustrating me... I want to check if a record exist then just update a field, if it doesnt exist then Add 1st and then update.... the following code,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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.