473,516 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timespan help

1 New Member
Hi,
I am pretty new to VB.NET. I am writing a program for keeping track of hours worked on different projects.
I need to save the values of a date and time selected by the user. Because they can be edited, I can't use DTP.DATE.NOW. Instead I use datetimepicker controls to allow the user to select the date and time. I place the values in a text box.

TxtBegTime.Text =DtpDate.Value.ToShortTimeString
TxtBegDate.text = DtpDate.Value.ToShortDateString

When the user adds (accepts) the time sheet, the data is written to a text file. using the value of the text box field ie.

PrintLine( 3, txtbegtime.text )

When the time sheet is updated at a later time to get the end time, the file is accessed, and the text boxes in the time sheet form are filled from the text file.

The user can then choose the date and time of completion, once again the dtp values are written to the appropriate text boxes in the time sheet form

TxtEndTime.Text =DtpDate.Value.ToShortTimeString
TxtEndDate.text = DtpDate.Value.ToShortDateString

I now want to determine the time span between the beginning time and date and the ending time and date. I would like to useTimeSpan to do this, but the data captured is not in date format. Is it possible to take the text saved and re-format it to a date that can be used to get the elapsed time using timespan, or am I going about this in the wrong way?

I know I can create an algorithim to seperate day, hour,min,sec from the strings and make the calculations manually, but I don't want to do that if it is not necessary.
Any help would be appreciated.
Thanks!
Sep 19 '06 #1
0 1427

Sign in to post your reply or Sign up for a free account.

Similar topics

2
21023
by: Jeff Shantz | last post by:
Hello, I'm developing a large statistics application for a call center. It often needs to calculate time spanning over months. For example, an agent's total talk time within 30 days. Since an agent talks about 5 hours per day, this comes out to about 150 hours of talk time per month. Fine. But, the DateTime and TimeSpan format strings...
3
13528
by: Ivan A. | last post by:
Hi! Why I can't serialize TimeSpan structure with XmlSerializer? This is what I do: using System; using System.IO; using System.Xml; using System.Xml.Serialization;
2
19065
by: DWalker | last post by:
In Visual Studio (Visual Basic) .NET 2002, I noticed that this: Dim Elapsed as DateTime = Now - Now gives a "compile time" error (error in the IDE), saying that the '-' operator is not defined for the Date datatype. On the other hand, Dim Elapsed as DateTime = Now + Now does not give a compile time error but it thinks you're...
10
38587
by: Charles Law | last post by:
If I display a TimeSpan I get something like 00:05:17.6217891 when what I would like to see is 00:05:18 Is there an easy way to get this output? Try as I might I just can't find it.
2
2931
by: ucasesoftware | last post by:
i translate a C# funtion to VB.NET and i have this : Shared Function isAllDay(ByVal ap As Appointment) As Boolean Return ap.DateBegin.TimeOfDay = TimeSpan.Zero AndAlso ap.DateEnd.TimeOfDay = TimeSpan.Zero End Function Error : = is not corret
13
2118
by: sd00 | last post by:
Hi all, can someone give me some coding help with a problem that *should* be really simple, yet I'm struggling with. I need the difference between 2 times (Target / Actual) However, these times will fall somewhere between a Start & End time Further more, there will be Break & Lunch times between Start & End. Example... Start 08:00 Break...
3
7932
by: Horselover Fat | last post by:
Hi, I have a column in a database that holds elapsed time in milliseconds and I want to display that column in a DataGrid in a specific format (d.hh:mm:ss.fff). However, the closest I can get is d.hh:mm:ss.ffffff. Code snippets follow: dt = new DataTable("Errors"); dt.Columns.Add("Occurred", typeof(TimeSpan)); // SELECT statement...
5
9766
by: style | last post by:
Hello In my custom configuration section, I'd like to specify an interval attribute which specifies an interval in milliseconds. I think it would be very comfortable to get this value directly as a TimeSpan. That's what I tryied: public TimeSpan Interval {
4
3277
by: Peter Proost | last post by:
Hi group, it's been a long time since the last time I've been here but I have a question. I'm working with timespan.parse for calculating a duration, I have to add strings which are in the following format 15:36:12 ==Hours, minutes, seconds but sometimes there is a string like 55:26:32 ==which is correct cause the production machine was...
4
6220
by: Massimo | last post by:
Hi to All, i'm using C# in .NET 2.0 and i have a DataTable A with a column of type TimeSpan used to store HOUR info. I'm trying to filter my DataTable A selecting only rows that have the column HOUR .... if i try to Call A.Select( " HOUR '10:30:00' " ) i receive an error ( cannot compare TimeSpan with String ...) if i try to call...
0
7276
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4773
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.