Results 1 to 8 of 8

Thread: Time data type and how to handle it

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    131

    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

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    IsDate does validate Time???

    It does date and time!!

    IsDate("12:00") would return true!

    b

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    131
    That's cool but how does it detect all times not just literal times like 12:00?

    God bless,
    Alvin

  4. #4
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    well you pass it any time and it will return true or false!!!

    Me is confused by question!!!!
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    131
    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

  6. #6
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    hmmmm

    do a replace before calling

    strData = replace(strdata,":", "/" )

    * replace ( [Main String], [New Letter], [old letter])


    Then call isDate
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    131
    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 1m for lunch break. This should calculate how many hours the car repair man worked in this repair monitoring system?

    God bless,
    Alvin

  8. #8
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width