473,412 Members | 5,385 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,412 software developers and data experts.

DateTime Hell

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?
Nov 21 '05 #1
10 1751
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." <te**@dennisys.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
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
Nov 21 '05 #2
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" <hm******@bellsouth.net> wrote in message
news:lJ******************@bignews6.bellsouth.net.. .
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." <te**@dennisys.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
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

Nov 21 '05 #3

"Dennis D." <te**@dennisys.com> wrote in message
news:e1****************@TK2MSFTNGP11.phx.gbl...
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?
Nov 21 '05 #4
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]" <i.***@enough.spam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

"Dennis D." <te**@dennisys.com> wrote in message
news:e1****************@TK2MSFTNGP11.phx.gbl...
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?

Nov 21 '05 #5
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]
Nov 21 '05 #6
That worked!
Thanks Tom Shelton [MVP]

Elegance is simple.

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

"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:10******************************@40tude.net.. .
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]

Nov 21 '05 #7
Nak
> 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.
Nov 21 '05 #8

"Dennis D." <te**@dennisys.com> wrote in message
news:u9*************@tk2msftngp13.phx.gbl...
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.
Nov 21 '05 #9

"Nak" <a@a.com> wrote in message
news:Og*************@TK2MSFTNGP09.phx.gbl...
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.
Nov 21 '05 #10
Nak
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.
Nov 21 '05 #11

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

Similar topics

22
by: Jim Hubbard | last post by:
I am reposting a portion of a thread that I am involved in under a new topic because it seems that there are still people that believe the whole "DLL Hell" myth. I hope I can shed some light on...
2
by: Nad | last post by:
Hello, dll hell has been eliminated in .NET using assembly versioning. I am new in .NET and would like to know if there is any dll-hell-equivalent in .NET Windows or Web development...
55
by: Jazzhouse | last post by:
Hi, How do you get the local date time as YYYYMMDDHHMMSS 14 digit string??? I am very new to C++, but if the MSDN tutorials are like that may be it is better to go with GCC... :) Ferhat
6
by: Franck Diastein | last post by:
Hi, I'm soon finishing my first app, and I learned a lot :-) I'm still having trouble with dates... When I pull a date from SQL Server, I store it in a DateTime variable and when I want to...
1
by: GreatB | last post by:
Bill Gates died in a car accident. He found himself in Purgatory being sized up by God . .. "Well, Bill, I'm really confused on this call. I'm not sure whether to send you to Heaven or Hell....
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
4
by: Michael Meckelein | last post by:
Hello, Wondering, if C# (framework 2.0) does not support parsing DateTime timezones in three letter acronyms. I would like to parse date strings like "2005 Nov 01 11:58:47.490 CST -6:00" but...
7
by: sherifffruitfly | last post by:
Hi, God I hate datetime string formatting... How do I get a string of the form "04-Oct-2006", for example, from a DateTime object? Thanks a jillion, cdj
11
by: Peter Holschbach | last post by:
Hi, I've the following line of code: result = DateTime.ParseExact("1999-12-01T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); where I get in result "result" "02.12.1999...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.