Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default The best way to specify time interval ...


Hi,

I'm writing and Xll Add-In for Excel.

I want to add a function that gives a result base on three parameters
- start time
- end time
- time interval

for start time and end time I project to use the same representation as
in excel.

But what for interval I don't know what to do.

For exemple :

How to specify :
at each 2hours 23 minutes
at each month
at each ....

Any idea are welcomed !

Nic


--
nicgendron
------------------------------------------------------------------------
nicgendron's Profile: http://www.excelforum.com/member.php...o&userid=25151
View this thread: http://www.excelforum.com/showthread...hreadid=396102

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default The best way to specify time interval ...

This may give you some ideas - you may need to do some other function but
this shows you you can specify different time intervals to use in
calculations. This function would rely on the user to choose the appropriate
unit for their interval, e.g. they could not specify an interval of 02:23,
but 2 hours 23 minutes would be 143 minutes. The function returns the number
of specified time intervals between the start and end times; time intervals
are specified with an integer number of units, the units are specified as
seconds, minutes, hours, etc as you can see below - so, for example,
MyTimeFunction(Now(), Now+TimeValue("01:20:00"), 10, tuMinutes) would return
8 meaning there are 8 periods of 10 minutes in the 1:20 elapsed time.

Public Enum TimeUnitEnum
tuSeconds = 1
tuMinutes = 2
tuHours = 3
tuDays = 4
tuWeeks = 5
tuMonths = 6
tuQuarters = 7
tuYears = 8
End Enum

Public Function MyTimeFunction(StartTime As Date, EndTime As Date,
IntervalTime As Integer, IntervalUnits As TimeUnitEnum) As Double
Dim TimeInterval As Date

Select Case IntervalUnits
Case tuSeconds
TimeInterval = TimeValue("00:00:01") * IntervalTime
Case tuMinutes
TimeInterval = TimeValue("00:01:00") * IntervalTime
Case tuHours
TimeInterval = TimeValue("01:00:00") * IntervalTime
Case tuDays
TimeInterval = IntervalTime
Case tuWeeks
TimeInterval = IntervalTime * 7
Etc....

End Select

MyTimeFunction = (EndTime - StartTime) / TimeInterval

End Function
--
- K Dales


"nicgendron" wrote:


Hi,

I'm writing and Xll Add-In for Excel.

I want to add a function that gives a result base on three parameters
- start time
- end time
- time interval

for start time and end time I project to use the same representation as
in excel.

But what for interval I don't know what to do.

For exemple :

How to specify :
at each 2hours 23 minutes
at each month
at each ....

Any idea are welcomed !

Nic


--
nicgendron
------------------------------------------------------------------------
nicgendron's Profile: http://www.excelforum.com/member.php...o&userid=25151
View this thread: http://www.excelforum.com/showthread...hreadid=396102


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with time interval [email protected] Excel Worksheet Functions 10 December 27th 08 11:08 PM
x-axis time interval John Charts and Charting in Excel 1 June 7th 08 02:23 AM
time interval calculation Sikander New Users to Excel 4 August 24th 07 06:56 AM
Time-interval protection Zurn[_15_] Excel Programming 0 September 29th 04 01:13 PM
Minimum time per interval Edmund Seet Excel Programming 7 August 27th 03 02:36 AM


All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"