Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Field Type for Time only

Status
Not open for further replies.

Triplex

Programmer
Oct 10, 2002
43
PH

I have a textbox that will accept time only (24 hrs format).
But I don't know what Data Field Type will I use in my Database.

And can you give some code on how to validate if the use input the right format or not.

Thanks,
Triplex
 
i personally use Character field type for such data. and on my form i use a textbox with format of 99:99. it's up to you for the validation.

kilroy [trooper] phils.
 
Depends what you want to do with the time. I use seconds-since-midnight because I need to do some calculations. Data input comes from three spinners that take hours, minutes & seconds and convert them to seconds for storage.

Geoff Franklin
 
Somewhat Like TorturedMind, I use character fields. Mine simply fill with datetime() conversions. This is done on the table and/or form levels:

Simple functions, such as ttoc() and right(), do adequately strip datetime() formats to programatically enter datetime() as time in appropriate character formats, SANS the date portion.

Additionally, user keyboard imputs must validate about 6 or 8 times for: 'am' 'pm' and digit levels on the 24 hour or 12 hour format.

':' is masked into your charactor field on the table and/or form level; so is the 'm' in 'am' and 'pm'

My way is probably not the best way, but it suffices well as a time field.

Philip M. Traynor, DPM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top