Hi all,

What is the best way to define a field in a table to contain Time? should
it be a character or datetime?
also, once it is defined in a table, how is best to utilize that field in a
form? like what input mask should it have and how do you stop the user from
entering an invalid time?
Is there a control (or does anyone have one?) that could be dropped on a
form that is already validated as a time field?

Thanks

HME

--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com

Re: time function by Fred

Fred
Thu Jun 01 00:27:49 CDT 2006

Depends on what you need to do with that time data. If you need to
manipulate it (add additional seconds, etc.), then use a datetime and ignore
the date part. If it's just for display purposes, you can use a character
field. You might be able to find a class that handles time on the UT
(www.universalthread.com)


--
Fred
Microsoft Visual FoxPro MVP


"HME" <helassaad@comcast.net> wrote in message
news:u-ednf8qpLvCyuPZnZ2dnUVZ_tOdnZ2d@comcast.com...
> Hi all,
>
> What is the best way to define a field in a table to contain Time? should
> it be a character or datetime?
> also, once it is defined in a table, how is best to utilize that field in
> a
> form? like what input mask should it have and how do you stop the user
> from
> entering an invalid time?
> Is there a control (or does anyone have one?) that could be dropped on a
> form that is already validated as a time field?
>
> Thanks
>
> HME
>
> --
>
>
> ---------------------------------------------------------------------
> "Are you still wasting your time with spam?...
> There is a solution!"
>
> Protected by GIANT Company's Spam Inspector
> The most powerful anti-spam software available.
> http://mail.spaminspector.com
>
>
>



Re: time function by Imaginecorp

Imaginecorp
Sat Jun 03 21:07:21 CDT 2006

try this class, will need some tweeking, I wrote it years ago but it works
change stuff like STR() to transform() to bring it uptodate
Good luck
Mohammed
**************************************************
*-- Class: reg_timetextbox (c:\its\libraries\reg_controls.vcx)
*-- ParentClass: textbox
*-- BaseClass: textbox
*-- Time Stamp: 06/03/06 09:54:07 PM
*
DEFINE CLASS reg_timetextbox AS textbox

FontName = "MS Sans Serif"
FontSize = 8
Hours = 12
Format = "!K"
Height = 19
InputMask = "99:99 AM"
MaxLength = 8
MousePointer = 99
MouseIcon = "..\graphics\normal02.cur"
SelectOnEntry = .T.
SpecialEffect = 1
Width = 71
ColorSource = 0
DisabledBackColor = RGB(224,223,227)
DisabledForeColor = RGB(0,0,0)
IntegralHeight = .T.
Name = "reg_timetextbox"

*-- adds or substract time, accepts 3 parameters , time , date ,
"Add"/"Minus"
PROCEDURE add_minus_time
Lparameters ptime,pdate,pdowhat
mdowhat = Iif(Alltrim(Upper(pdowhat)) = "ADD",.T.,.F.)
Local preturn
Store 0 To mhours,mminutes,mdate
Store "" To mampm
If mdowhat
mminutes = Val(Substr(ptime,4,2)) + Val(Substr(This.Value,4,2))
If mminutes > 59
mhours = Int(mminutes/60)
mminutes = Mod(mminutes,60)
Endif
mhours = Val(Left(ptime,2))+Val(Left(This.Value,2))
mhours = Iif(mhours > 12,(mhours - 12),mhours)
mpmam = Iif(mhours > 12,Iif(Right(ptime,2) =
"AM","PM","AM"),Right(ptime,2))
mreturn = Alltrim(Str(mhours,2))+" "+Str(mminutes,2)+" "+Left(mpmam,1)
Else
Endif
Return mreturn
ENDPROC

PROCEDURE Valid
If !Empty(Left(This.Value,2)) Or !Empty(Substr(This.Value,4,2))
If !Inlist(Upper(Right(This.Value,2)),"PM","AM")
=Messagebox("Must enter the 'AM'/'PM'for this time...",48,its_logo)
This.Value = ""
This.Refresh
Return .F.
Endif
If Val(Left(This.Value,2)) > 12
=Messagebox("You have entered an invalid hour for the
time...",48,its_logo)
This.Value = ""
This.Refresh
Return .F.
Endif
If Val(Substr(This.Value,4,2)) > 60
=Messagebox("You have entered an invalid minute for the
time...",48,its_logo)
This.Value = ""
This.Refresh
Return .F.
Endif
Endif
ENDPROC
ENDDEFINE
*
*-- EndDefine: reg_timetextbox
**************************************************


"HME" <helassaad@comcast.net> wrote in message
news:u-ednf8qpLvCyuPZnZ2dnUVZ_tOdnZ2d@comcast.com...
> Hi all,
>
> What is the best way to define a field in a table to contain Time? should
> it be a character or datetime?
> also, once it is defined in a table, how is best to utilize that field in
> a
> form? like what input mask should it have and how do you stop the user
> from
> entering an invalid time?
> Is there a control (or does anyone have one?) that could be dropped on a
> form that is already validated as a time field?
>
> Thanks
>
> HME
>
> --
>
>
> ---------------------------------------------------------------------
> "Are you still wasting your time with spam?...
> There is a solution!"
>
> Protected by GIANT Company's Spam Inspector
> The most powerful anti-spam software available.
> http://mail.spaminspector.com
>
>
>



Re: time function by HME

HME
Mon Jun 05 21:49:06 CDT 2006

thank you Mohamed, I'll give it a try.

HME

--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com


"Imaginecorp" <imaginecorp@msn.com> wrote in message
news:uhuQfu3hGHA.1264@TK2MSFTNGP05.phx.gbl...
> try this class, will need some tweeking, I wrote it years ago but it works
> change stuff like STR() to transform() to bring it uptodate
> Good luck
> Mohammed
> **************************************************
> *-- Class: reg_timetextbox (c:\its\libraries\reg_controls.vcx)
> *-- ParentClass: textbox
> *-- BaseClass: textbox
> *-- Time Stamp: 06/03/06 09:54:07 PM
> *
> DEFINE CLASS reg_timetextbox AS textbox
>
> FontName = "MS Sans Serif"
> FontSize = 8
> Hours = 12
> Format = "!K"
> Height = 19
> InputMask = "99:99 AM"
> MaxLength = 8
> MousePointer = 99
> MouseIcon = "..\graphics\normal02.cur"
> SelectOnEntry = .T.
> SpecialEffect = 1
> Width = 71
> ColorSource = 0
> DisabledBackColor = RGB(224,223,227)
> DisabledForeColor = RGB(0,0,0)
> IntegralHeight = .T.
> Name = "reg_timetextbox"
>
> *-- adds or substract time, accepts 3 parameters , time , date ,
> "Add"/"Minus"
> PROCEDURE add_minus_time
> Lparameters ptime,pdate,pdowhat
> mdowhat = Iif(Alltrim(Upper(pdowhat)) = "ADD",.T.,.F.)
> Local preturn
> Store 0 To mhours,mminutes,mdate
> Store "" To mampm
> If mdowhat
> mminutes = Val(Substr(ptime,4,2)) + Val(Substr(This.Value,4,2))
> If mminutes > 59
> mhours = Int(mminutes/60)
> mminutes = Mod(mminutes,60)
> Endif
> mhours = Val(Left(ptime,2))+Val(Left(This.Value,2))
> mhours = Iif(mhours > 12,(mhours - 12),mhours)
> mpmam = Iif(mhours > 12,Iif(Right(ptime,2) =
> "AM","PM","AM"),Right(ptime,2))
> mreturn = Alltrim(Str(mhours,2))+" "+Str(mminutes,2)+" "+Left(mpmam,1)
> Else
> Endif
> Return mreturn
> ENDPROC
>
> PROCEDURE Valid
> If !Empty(Left(This.Value,2)) Or !Empty(Substr(This.Value,4,2))
> If !Inlist(Upper(Right(This.Value,2)),"PM","AM")
> =Messagebox("Must enter the 'AM'/'PM'for this time...",48,its_logo)
> This.Value = ""
> This.Refresh
> Return .F.
> Endif
> If Val(Left(This.Value,2)) > 12
> =Messagebox("You have entered an invalid hour for the
> time...",48,its_logo)
> This.Value = ""
> This.Refresh
> Return .F.
> Endif
> If Val(Substr(This.Value,4,2)) > 60
> =Messagebox("You have entered an invalid minute for the
> time...",48,its_logo)
> This.Value = ""
> This.Refresh
> Return .F.
> Endif
> Endif
> ENDPROC
> ENDDEFINE
> *
> *-- EndDefine: reg_timetextbox
> **************************************************
>
>
> "HME" <helassaad@comcast.net> wrote in message
> news:u-ednf8qpLvCyuPZnZ2dnUVZ_tOdnZ2d@comcast.com...
> > Hi all,
> >
> > What is the best way to define a field in a table to contain Time?
should
> > it be a character or datetime?
> > also, once it is defined in a table, how is best to utilize that field
in
> > a
> > form? like what input mask should it have and how do you stop the user
> > from
> > entering an invalid time?
> > Is there a control (or does anyone have one?) that could be dropped on a
> > form that is already validated as a time field?
> >
> > Thanks
> >
> > HME
> >
> > --
> >
> >
> > ---------------------------------------------------------------------
> > "Are you still wasting your time with spam?...
> > There is a solution!"
> >
> > Protected by GIANT Company's Spam Inspector
> > The most powerful anti-spam software available.
> > http://mail.spaminspector.com
> >
> >
> >
>
>