473,372 Members | 883 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,372 software developers and data experts.

DateTime difference using TimeSpan

I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:

12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM

How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?

I want to have the results expressed in days, hours, minutes and seconds.
Nov 21 '05 #1
5 11498
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <La*******@discussions.microsoft.com> wrote
in news:CE**********************************@microsof t.com:
How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?


You might need to Cdate your string date/times to be accepted as a valid
time format.

You can use DateDiff to get the difference betwen two dates. The results
will be returned as a TimeInterval which has several properties to get the
minutes, hours, days.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2
how can I get the results from "DateDiff" to show all minutes?

Thanks
"Lucas Tam" wrote:
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <La*******@discussions.microsoft.com> wrote
in news:CE**********************************@microsof t.com:
How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?


You might need to Cdate your string date/times to be accepted as a valid
time format.

You can use DateDiff to get the difference betwen two dates. The results
will be returned as a TimeInterval which has several properties to get the
minutes, hours, days.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 21 '05 #3
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <La*******@discussions.microsoft.com>
wrote in news:C4**********************************@microsof t.com:
how can I get the results from "DateDiff" to show all minutes?

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfSystemTimeSpanClassTopic.asp
You would use the TotalMinutes property.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #4

Try it this way:
' Create two valid dates
Dim dLast As Date = CDate([strDate])
Dim dNow As Date = Now

Dim iTime As TimeSpan = dNow.Subtract(dLast)

iTime.Minutes returns the minutes of the TimeSpan object.

Hope this helps,
Dennis
"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:

12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM

How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?

I want to have the results expressed in days, hours, minutes and seconds.

Nov 21 '05 #5
This what I've been looking for and trying to do.

Thanks

"Dennis Powell" wrote:

Try it this way:
' Create two valid dates
Dim dLast As Date = CDate([strDate])
Dim dNow As Date = Now

Dim iTime As TimeSpan = dNow.Subtract(dLast)

iTime.Minutes returns the minutes of the TimeSpan object.

Hope this helps,
Dennis
"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:

12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM

How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?

I want to have the results expressed in days, hours, minutes and seconds.


Nov 21 '05 #6

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

Similar topics

2
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...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
1
by: Ron | last post by:
How can I find the difference in seconds of two DateTime objects. I have looked at the Subtract method but this gives me back another DateTime object. Thanks, Ron
5
by: Nikeman | last post by:
good day, I simply would like to know as to how I can parse seconds to convert them into equivalent DateTime representation. To be more persice, I have a DirectShow app written in VB.NET, with a...
1
by: JIM.H. | last post by:
Hello I have TextBox1 this keeps date and time information and I need to compare this DateTime with the current DateTime and find difference in hour. How can I do this in VB.Net? Thanks,
2
by: Mike | last post by:
I have an ASP.NET form(using C#) with several text boxes and when the user places a date in the first textbox and clicks a button, I would like to populate the remaining textboxes with various...
8
by: ajs | last post by:
I have a process that verifies that a server is running. If the server stops responding I send an email to a support person. Now I want to add a downtime indicator so that my code does not send...
1
by: =?Utf-8?B?RGFwcGVyRGFuSEBub3NwYW0ubm9zcGFt?= | last post by:
Given the example below, can someone explain why TimeSpan.TotalDays gives a different result than subtracting 2 DateTime.ToOADates? I am completely stumped. Thanks in advance, Dan Example...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.