3 Replies - 15516 Views - Last Post: 06 October 2008 - 05:22 AM Rate Topic: -----

#1 luisorosco  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-October 08

datetime to integer

Post icon  Posted 05 October 2008 - 07:29 PM

i M trying to convert a time span (the difference of two datetimepickers into an integer so i can used to charge a X amount of dollars per day.

is that possible?

Option Strict On
Public Class RentForm


	Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
		'figure the rental cost
		Dim datebegday As Date 'day of car pick up
		Dim datelastday As Date 'day of car drop off
		Dim intbegread As Integer 'beginning odometer reading
		Dim intlastread As Integer 'last odometer reading
		Dim dectotal As Decimal 'total cost of rental service
		Dim intdays As Integer ' total of day rented
		Dim decmiles As Decimal ' total of miles added

		'get the user data input

		datebegday = Date.Parse(pickuptimepicker.Text)
		datelastday = Date.Parse(returnTimePicker.Text)
		intbegread = Integer.Parse(beginningTextBox.Text)
		intlastread = Integer.Parse(lastTextBox.Text)

		'figure total

in a beginner.. can you tell?


Is This A Good Question/Topic? 0
  • +

Replies To: datetime to integer

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: datetime to integer

Posted 05 October 2008 - 07:41 PM

i think it's in vb.net

lets try the datediff method in vb.net will return the no of days you should multiply the amount with that day for more reference use the following link

http://msdn.microsof...t6f(VS.80).aspx

next time post the question in the correct form then only you will get immediate response
Was This Post Helpful? 1
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: datetime to integer

Posted 05 October 2008 - 07:42 PM

Moved to VB.NET :)
Was This Post Helpful? 0
  • +
  • -

#4 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: datetime to integer

Posted 06 October 2008 - 05:22 AM

You could also use a TimeSpan by doing something like...

Days = EndDate.Subtract(StartDate).TotalDays


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1