Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Add & Subtract Time


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-24-2007, 04:02 PM
Knows the basics
 
Join Date: Aug 2007
Location: Arkansas
Posts: 52
Default Add & Subtract Time

I need to know how to add/subtract time.
I'm creating a numpad that will display the time in increments(1:00,5:00,10:00 so on and so forth).
The user only needs to see the time he/she inputs.I can do that.But what I cant do is to so the sum.
I suppose I could convert time in to ticks but that is lost on me.

Here I have an example of what I'm working on:

(03:25-03:45=00:20)
then
(09:00+21:00=11:40)

As you see I'm using 24 hour display and I subtracted the 20min from the run time of 12 hours.
Reply With Quote
  #2 (permalink)  
Old 10-24-2007, 04:19 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 611
Default

I think I really didn't get your problem.
You could easily use Time and TimeParse for your calculations.

After setting the preferred time format (24 hour display) with
Code:
TimeFormat("HH:mm")
you could do something like this
Code:
Label1.Text = Time(TimeParse("03:45") - TimeParse("03:25"))
wich results in Label1.Text = "00:20"


specci48
Reply With Quote
  #3 (permalink)  
Old 10-24-2007, 04:23 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,470
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by cdeane View Post
I suppose I could convert time in to ticks but that is lost on me
This is best (and easiest) thing to do to perform accurate time calculations - it's not difficult to get your head round it. Ticks are just a count of small increments of time from a defined starting time. Convert to ticks, do the sums and convert back at the end. Just read through Help->Main Help->Keywords->Time to see what can be done.
Reply With Quote
  #4 (permalink)  
Old 10-24-2007, 04:30 PM
Knows the basics
 
Join Date: Aug 2007
Location: Arkansas
Posts: 52
Default

Ill give them a try.
Thank you very much
Reply With Quote
  #5 (permalink)  
Old 10-24-2007, 05:41 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,956
Default

See the Date and Time tutorial: Date and Time
Reply With Quote
  #6 (permalink)  
Old 11-07-2007, 07:07 PM
Junior Member
 
Join Date: Oct 2007
Posts: 25
Default

Hello!

A question about ticks, time dates...

What about the years with february with 29 days? Is this included in ticks.

Thx, kavka
Reply With Quote
  #7 (permalink)  
Old 11-07-2007, 07:29 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,956
Default

Ticks represent 1 / 10,000,000 of a second.
When you use Date (TicksValue), leap years and regular years are considered.
Reply With Quote
  #8 (permalink)  
Old 11-07-2007, 07:33 PM
Junior Member
 
Join Date: Oct 2007
Posts: 25
Default

So you think that calculation of dates and times is better to be performed with ticks than with TimeParse?

Thx
Reply With Quote
  #9 (permalink)  
Old 11-07-2007, 07:36 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,956
Default

It is easier to convert the time string to ticks with TimeParse / DateParse and then do the calculations with the ticks values.
Reply With Quote
  #10 (permalink)  
Old 11-27-2007, 10:09 PM
Junior Member
 
Join Date: Oct 2007
Posts: 25
Default

Hello!

I want to add time values togeder which are in a table (all in one column). The sum will be higher then 24 hours and I need the value in hour:minute form (345:23). How is this possible to do?

These time values are sorted by dates, I want to add togeder these time values for previous six days. Not the last six entries but the last six days.

Thx
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
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
Mars Time alfcen Share Your Creations 4 05-12-2008 11:21 AM
Adding time Sascha K. Questions & Help Needed 3 03-23-2008 07:46 PM
Time question Cableguy Questions & Help Needed 2 01-05-2008 10:49 AM
Time Zone alfcen Basic4ppc Wishlist 8 10-05-2007 05:47 AM


All times are GMT. The time now is 12:16 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0