|
-
Oct 23rd, 2002, 07:52 PM
#1
Thread Starter
Addicted Member
Time data type and how to handle it
Good morning, it's easy to check if the data entered on a textbox is a date using IsDate functions but how do you check for time, is there a IsTime function?
Also, how do you calculate time in VB. My monitoring system which deal in vehical repair has to monitor the amount time minus 1 hour for lunch break for a mechanic. The difference minues lunch time would then be multiplied by the mechanic's rate to determine the total labor costs.
God bless,
Alvin
-
Oct 23rd, 2002, 08:13 PM
#2
PowerPoster
IsDate does validate Time???
It does date and time!!
IsDate("12:00") would return true!
b
-
Oct 23rd, 2002, 10:01 PM
#3
Thread Starter
Addicted Member
That's cool but how does it detect all times not just literal times like 12:00?
God bless,
Alvin
-
Oct 24th, 2002, 02:36 AM
#4
KING BODWAD XXI
-
Oct 24th, 2002, 02:51 AM
#5
Thread Starter
Addicted Member
Thanks again for the reply. If a date is entered it would still return true but then that would be incorrect as it should be time?
txtTime = "12/12/12"
If IsDate (txtTime) = True 'which shouldn't be because it's a date and not time
God bless,
Alvin
-
Oct 24th, 2002, 03:55 AM
#6
KING BODWAD XXI
hmmmm
do a replace before calling
strData = replace(strdata,":", "/" )
* replace ( [Main String], [New Letter], [old letter])
Then call isDate
-
Oct 24th, 2002, 04:43 AM
#7
Thread Starter
Addicted Member
Thanks again, replace, nice function, first time I'll use it.
How do you perform artithmetic operations on time if it is converted into string by the way. Say the startTime is 9:30 am and the endTime is 1:30pm then minus 1 hour for 12:00pm to 1 m for lunch break. This should calculate how many hours the car repair man worked in this repair monitoring system?
God bless,
Alvin
-
Oct 24th, 2002, 05:10 AM
#8
KING BODWAD XXI
The DateAdd Function should do this
[NewTime] = dateadd(-1,"h", [Original Time])
"h" Means hour
-1 to subtract instead of add
See msdn for other info on this function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|