Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > MS Technologies ( ASP, VB, C#, .NET )
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 11-07-2005, 01:29 PM   #1 (permalink)
joehouse
Registered User
 
joehouse's Avatar
 
Join Date: Jun 2005
Posts: 9
joehouse is on a distinguished road
Unhappy Time... horrible horrible time...

Okay... I've put down my bag of paintchips and I've promised not to eat anymore of them [at least for today]. So know I'm going to ask since I'm having a catastrophic brain fart.

I cant figure out how to get Acces [and I swear I can remember doing this before] to take a start time and subtract it from an end time to get s time spent for a project...

the fields are all in the same table.

TIn
TOut
TTotal

They're all in short time format [ie military time]. The only way I can think of it is to make a module that'll do it and then have TTotal reference the MTTotal [module].

But here's where the brain fart comes in... I cant remember the way I need to set up the module. Haven't touched VB in tooooooooooooooooooo long.
__________________
joehouse is offline   Reply With Quote
Old 11-23-2005, 09:51 AM   #2 (permalink)
Joel Egghead
Registered User
 
Join Date: Oct 2005
Posts: 5
Joel Egghead is on a distinguished road
Im not sure if you are using .net or vb6 but, in vb.net it’s a built in to the Date and time datatype. Other words a function like this would work:
Private Sub Time()
Dim StartTime As Date
Dim EndTime As Date
Dim TotalHours, TotalMin As Integer


StartTime = "11/22/05 17:00:00"
EndTime = "11/23/05 01:36:00"


If StartTime.Hour > EndTime.Hour Then
'IF Time.hour goes past 23:59 to next day 24 hours - start hour + Time spent in new day
TotalHours = (24 - StartTime.Hour) + EndTime.Hour
Else
TotalHours = EndTime.Hour - StartTime.Hour
End If

If StartTime.Minute > EndTime.Minute Then
'IF Time.minute goes past 60 min – start min + End Min
TotalMin = (60 - StartTime.Minute) + EndTime.Minute
'Since we already added the hour in the hour section we have to delete it here because it really wasn’t a full hour
TotalHours = TotalHours - 1
Else
TotalMin = EndTime.Minute - StartTime.Minute
End If
txtFullTime.Text = TotalHours & "hrs. & " & TotalMin & "min."
End Sub

Now you can add more to this to cover milliseconds as well but this would work for hours and minutes it also holds your days of the year.
Hope this helps
It’s been awhile since I programmed in vb6 but I’m thinking they to had the same date datatype.
__________________
Joel Egghead is offline   Reply With Quote
Reply


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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi Guys. First Time Poster ferdinand633 Lounge 11 03-18-2005 11:23 AM
network time synchronisation in java bossebo Java 1 06-21-2004 05:17 PM
Adjusting date() function for time zones Epsilon PHP 1 02-27-2004 02:55 AM
What a waste of time! saline Saline's Brain Teasers 1 03-25-2003 12:57 PM
Assign value to a variable depending on time AOD PHP 10 02-12-2003 03:06 PM


All times are GMT -8. The time now is 08:15 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle