PC Review


Reply
Thread Tools Rate Thread

DateTime Hell

 
 
Dennis D.
Guest
Posts: n/a
 
      9th Aug 2004
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?


 
Reply With Quote
 
 
 
 
Hal Rosser
Guest
Posts: n/a
 
      10th Aug 2004
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

"Dennis D." <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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?
>
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004


 
Reply With Quote
 
Dennis D.
Guest
Posts: n/a
 
      10th Aug 2004
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.

"Hal Rosser" <(E-Mail Removed)> wrote in message
news:lJTRc.14516$(E-Mail Removed)...
> 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
>
> "Dennis D." <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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?
> >
> >

>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004
>
>



 
Reply With Quote
 
Jeff Johnson [MVP:VB]
Guest
Posts: n/a
 
      10th Aug 2004

"Dennis D." <(E-Mail Removed)> wrote in message
news:e1sGg%(E-Mail Removed)...

> 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?


 
Reply With Quote
 
Dennis D.
Guest
Posts: n/a
 
      10th Aug 2004
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.

"Jeff Johnson [MVP:VB]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Dennis D." <(E-Mail Removed)> wrote in message
> news:e1sGg%(E-Mail Removed)...
>
> > 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?
>
>



 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      10th Aug 2004
On Mon, 9 Aug 2004 15:59:05 -0700, Dennis D. wrote:

> 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
--
Tom Shelton [MVP]
 
Reply With Quote
 
Dennis D.
Guest
Posts: n/a
 
      10th Aug 2004
That worked!
Thanks Tom Shelton [MVP]

Elegance is simple.

Dennis D.
http://www.dennisys.com/

"Tom Shelton" <(E-Mail Removed)> wrote in message
news:10obydna88mh5$.(E-Mail Removed)...
> On Mon, 9 Aug 2004 15:59:05 -0700, Dennis D. wrote:
>
> > 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
> --
> Tom Shelton [MVP]



 
Reply With Quote
 
Nak
Guest
Posts: n/a
 
      10th Aug 2004
> 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.


 
Reply With Quote
 
Jeff Johnson [MVP: VB]
Guest
Posts: n/a
 
      10th Aug 2004

"Dennis D." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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.


 
Reply With Quote
 
Jeff Johnson [MVP: VB]
Guest
Posts: n/a
 
      10th Aug 2004

"Nak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> > 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?


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


 
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
build Dictionary< DateTime , decimal > from List < DateTime > John A Grandy Microsoft C# .NET 1 5th Feb 2009 03:08 AM
Millisecond values missing when inserting datetime into datetime column of sql Server Manikandan Microsoft C# .NET 4 18th Jul 2007 08:59 PM
How can I save a DateTime from my C# program into a SQL Server (datetime) database column. Steve Kershaw Microsoft ASP .NET 5 29th Aug 2006 03:10 AM
DateTime Hell Franck Diastein Microsoft C# .NET 6 14th Dec 2004 09:38 PM
Re: converting Unix datetime count to .Net DateTime object Mark Worrall Microsoft C# .NET 1 4th Feb 2004 07:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:56 AM.