473,324 Members | 2,581 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,324 software developers and data experts.

Calculating days from dates

Hi

How can I calculate days from the two dates entered in date time picker
fields on winform by a user?

Thanks

Regards


Sep 28 '08 #1
3 4289
John,

You first have to define what is a day.

For some people is it just two dates, (which means that a millisecond is one
day), for others it is at the second exact.

Cor
"John" <in**@nospam.infovis.co.ukschreef in bericht
news:OK**************@TK2MSFTNGP06.phx.gbl...
Hi

How can I calculate days from the two dates entered in date time picker
fields on winform by a user?

Thanks

Regards

Sep 28 '08 #2
You should use DateTime.Subtract to get a timespan, and then totaldays, as
in this example:

Module Module1

Sub Main()
Dim dt1 As New DateTime(2008, 9, 11)
Dim dt2 As New DateTime(2008, 9, 15)

Console.Out.WriteLine("Days: " & dt2.Subtract(dt1).TotalDays())
Console.In.ReadLine()
End Sub

End Module
"John" <in**@nospam.infovis.co.ukwrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
Hi

How can I calculate days from the two dates entered in date time picker
fields on winform by a user?

Thanks

Regards

Sep 28 '08 #3
On Sep 28, 6:51*pm, "John" <i...@nospam.infovis.co.ukwrote:
Hi

How can I calculate days from the two dates entered in date time picker
fields on winform by a user?

Thanks

Regards
Assuming you have 2 DateTimePicker controls, you can use substract
method to get result as string:

'Calculate DateTimePicker1 - DateTimePicker2
'-----Begin-----
Dim str As String
str = DateTimePicker1.Value.Date.Subtract _
(DateTimePicker2.Value.Date).Days.ToString()
'Show difference in message box
MsgBox(str)
'-----End------

Hope this helps,

Onur Güzel
Sep 28 '08 #4

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

Similar topics

4
by: Hans Gruber | last post by:
Hi all, I have been struggling with a problem all day, I have been unable to come up with a working solution. I want to write a function which takes 2 unix timestamps and calculates the...
4
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can...
10
by: riki | last post by:
hello, i need to calculate num of days between 2 dates... i get separate parts of dates from html form, then i need to "make" begining and ending date and calculate difference between them......
1
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
2
by: bufbec | last post by:
I have worked on this for hours and can't come up with a solution. Hope someone can help me. I have a table called TMBS_HMAUDIT_PARMS. this table contains data to tell me how often a person is...
4
by: Yotam | last post by:
Hi, I need some help with JS. I will be grateful, if you can help me out. I have two date fields (check in, check out) and "number of days" field. I want the script to calculate automatically...
9
by: clintonb | last post by:
I'm looking for a way to calculate the number of days between two dates using standard C++ functions. Would it be as simple as just using the difftime() function and then dividing that result by...
13
by: drago | last post by:
Hi guys, good to be here... I am struggling to calculated days in invoice system...Ok...The dates fields are of two kinds...One is the invoice start date and end date... The other one is the contract...
6
by: krishnakant Mane | last post by:
hello, I am strangely confused with a date calculation problem. the point is that I want to calculate difference in two dates in days. there are two aspects to this problem. firstly, I can't get...
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
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
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
1
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.