PC Review


Reply
Thread Tools Rate Thread

Calculating days from dates

 
 
John
Guest
Posts: n/a
 
      28th Sep 2008
Hi

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

Thanks

Regards




 
Reply With Quote
 
 
 
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      28th Sep 2008
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Hi
>
> How can I calculate days from the two dates entered in date time picker
> fields on winform by a user?
>
> Thanks
>
> Regards
>
>
>
>


 
Reply With Quote
 
Family Tree Mike
Guest
Posts: n/a
 
      28th Sep 2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> How can I calculate days from the two dates entered in date time picker
> fields on winform by a user?
>
> Thanks
>
> Regards
>
>
>
>


 
Reply With Quote
 
kimiraikkonen
Guest
Posts: n/a
 
      28th Sep 2008
On Sep 28, 6:51*pm, "John" <i...@nospam.infovis.co.uk> wrote:
> 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
 
Reply With Quote
 
jano
Guest
Posts: n/a
 
      16th Dec 2008
Hi John and all!

I found this:
http://www.bizsupportonline.net/info...s-formulas.htm

but it didn't work for me(

note:
when I entered the functions: number, substring and floor; and clicked on
'verify formula', the infopath displayed Error indicating that there
shouldn't be any spaces between numbers 'startDate, 9, 2' etc.
So, I repaired the formulas deleting all spaces between numbers, but it
still didn't work after that.

I'm starting to believe that there is no other way to do this than code,
which I'm trying to avoid. So any ideas would be greatly appreciated.

thx,
jano

"John" wrote:

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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating the days between two dates pandd15 Microsoft Excel Worksheet Functions 2 15th Sep 2009 03:18 PM
Conditional Formatting Dates calculating 10 days and 30 days from a certain date Sioux Microsoft Excel Worksheet Functions 2 11th Oct 2007 02:04 PM
Calculating number of days between two dates that fall between two other dates richard.goodger@gmail.com Microsoft Excel Misc 5 26th Oct 2005 06:18 PM
Calculating # of busn days, not just calendar days, between 2 dates? StargateFanFromWork Microsoft Excel Programming 1 29th Jun 2004 08:31 PM
Calculating the days between 2 dates jfriend Microsoft Outlook Program Addins 1 28th Aug 2003 08:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:48 AM.