DateTime Hell

  • Thread starter Thread starter Dennis D.
  • Start date Start date
D

Dennis D.

Trying to write an itinerary program.

Got date and time from date time picker
Converted it to date variables to extract the date and the time
The form has first a textbox displaying the starting date and time via the
picker.
The next few text boxes allow user input of hours and minutes for elapsed
time of occurring events
Each text box subtracts or adds from the previous box to reveal a new date
time

Example:
The start date is 9/9/2004 2:15:00 AM
I want to subtract 4 hours and 30 minutes (a changeable user input to a
textbox) from the start date and produce a new date time (which is converted
to a string and output to a display).

The problem: How can I get the minutes to borrow from the hours, and the
hours to borrow from the date when that is required.

Also, for the output display, is it typical to use a textbox or a label
control for output results?
 
you don't have to do all that mess
use DateAdd , DateDiff, etc
--but if you're working from text boxes and trying to simulate what vb can
do -
you can use the integer division operator "\" and the "Mod" operator to
divide by 60 and get the remainder
 
The textbox that gets the user input defaults to the system date unless I
clone the date from the date time picker and either add or subtract the
hours and minutes.

I'm still left with the question: How do I get vb to borrow from the parent
variable values?

All that mess is the form.

Thanks. Could use more input.

Here's a URL:
http://www.dennisys.com/physical_science/vb/dates.htm

ed.
 
The textbox that gets the user input defaults to the system date unless I
clone the date from the date time picker and either add or subtract the
hours and minutes.

I'm still left with the question: How do I get vb to borrow from the
parent
variable values?

All that mess is the form.

Thanks. Could use more input.

This is not as hard as you seem to be making it. Can you post the code that
you have tried?
 
Well, if it's not as hard as I have been making it, then what is the answer?
How do I get vb to borrow from the
parent variable values?
A simple answer will suffice.

Dennis D.
 
Trying to write an itinerary program.

Got date and time from date time picker
Converted it to date variables to extract the date and the time
The form has first a textbox displaying the starting date and time via the
picker.
The next few text boxes allow user input of hours and minutes for elapsed
time of occurring events
Each text box subtracts or adds from the previous box to reveal a new date
time

Example:
The start date is 9/9/2004 2:15:00 AM
I want to subtract 4 hours and 30 minutes (a changeable user input to a
textbox) from the start date and produce a new date time (which is converted
to a string and output to a display).

The problem: How can I get the minutes to borrow from the hours, and the
hours to borrow from the date when that is required.

Also, for the output display, is it typical to use a textbox or a label
control for output results?

Dim n as datetime = datetime.now
dim m as datetime = n.subtract(new timespan(4, 30, 0))

console.writeline(n)
console.writeline(m)

HTH
 
This is not as hard as you seem to be making it. Can you post the code
that
you have tried?

:-| Isn't that the nature of this group? For people are *are* finding
things hard to recevie advice from those in the know?

Nick.
 
Well, if it's not as hard as I have been making it, then what is the answer?
How do I get vb to borrow from the
parent variable values?
A simple answer will suffice.

Hal's suggestion of using DateAdd() and/or DateDiff() was a simple answer.
Since you didn't seem to understand it, I figured you were completely lost
and I wanted to see what path you were going down. However, Tom's answer
seems to have done the trick. I just hope he didn't do your homework for
you.

People are in these groups to help of their own free will, and they'll be
quite happy to stop helping those who get snippy.
 
:-| Isn't that the nature of this group? For people are *are* finding
things hard to recevie advice from those in the know?

Absolutely. But Hal gave him an answer and he seemed to skip right past it.
 
Hi,
Absolutely. But Hal gave him an answer and he seemed to skip right past
it.

Point taken, I hate it when people don't even acknowledge your reply, so I
shall shut up! ;-)

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top