473,395 Members | 2,795 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,395 software developers and data experts.

Number of hours in date range

Hi,
Is ther a simple way to calculate number of hours in a date range. (dtFrom
as date , dtTo as date)
Had a look at timespan, but can's see that it's possible to add dates.

Tnx
Totto
Nov 20 '05 #1
4 2822
Hi,

Dim ts As New TimeSpan

ts = Now.Subtract(DateTime.Parse("2/2/2004"))

Me.Text = (ts.Days * 24 + ts.Hours).ToString

Ken

------------------------------

"Totto" <ta*********@norcon.no> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
Hi,
Is ther a simple way to calculate number of hours in a date range. (dtFrom
as date , dtTo as date)
Had a look at timespan, but can's see that it's possible to add dates.

Tnx
Totto

Nov 20 '05 #2
Cor
Hi Totto,

Look at timespan to the methods totalhours, add and subtract. It goes a
little bit on a totally different way than we are used to.

I hope this helps?

Cor
Nov 20 '05 #3
"Totto" <ta*********@norcon.no> schrieb
Hi,
Is ther a simple way to calculate number of hours in a date range.
(dtFrom as date , dtTo as date)
Had a look at timespan, but can's see that it's possible to add
dates.


Calculate hours or add dates?
dim ts as timespan
ts = dtto.subtract(dtfrom)
msgbox(ts.totalhours)
Add days to a date:
d = d.adddays(5)

Add timespans:
ts3 = ts1.add(ts2)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
* "Totto" <ta*********@norcon.no> scripsit:
Is ther a simple way to calculate number of hours in a date range. (dtFrom
as date , dtTo as date)
Had a look at timespan, but can's see that it's possible to add dates.


\\\
Dim ts As TimeSpan = d1.Subtract(d2)
MsgBox(ts.TotalHours.ToString())
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

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

Similar topics

4
by: Mark | last post by:
Hi I have been trying to convert the week number to a range of dates that I can use. It should be fairly simple for you guru's out there but for us mere mortals it is beyond our grasp. I know...
2
by: Doug1962 | last post by:
I would like to run a query every date to extract only the records that have been added to the database within my criteria for a 24 hour period. I.E. I would like the query to extract records...
5
by: ????? | last post by:
I have an access query which gets data from a number of different tables. Although the tables have primary key fields, the order in which the records are returned means that none of these are in...
1
by: serge | last post by:
Right now the database I am working with is storing time in an Integer data type and is storing the time value in seconds. The application does not allow entering seconds. It accepts minutes and...
3
by: Tim Chase | last post by:
I've been trying to come up with a good algorithm for determining the starting and ending dates given the week number (as defined by the strftime("%W") function). My preference would be for a...
8
by: King | last post by:
Hi I have following MS Acess query Here is the query ID Name Prgm ID Client ID Date Start Time End Time Minutes C4 Trisha TIP DEK0703 7 /7 /2006...
2
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
4
realin
by: realin | last post by:
hi guys.. I have made a function which counts the numbers of days or hours or minutes from the current datetime to the give datetime.. but i am confused while displaying number of days along with...
5
by: jambonjamasb | last post by:
I am wanting to create a report that summarises the number of items within a date range. For example I have a FIELD called System_Change. This is a drop down COMBOBOX that uses words like unix,...
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: 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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
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...

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.