Article ID: 138980
Article Last Modified on 8/24/1999
* Begin Mktables.prg
*
CREATE DATABASE Dt_dbc
CREATE TABLE Dt_tab (key1 C(5) PRIMARY KEY, date_time T)
FOR nI=1 TO 5
INSERT INTO dt_tab (key1, date_time) VALUES ;
(PADL(ALLTRIM(STR(nI)),5,'0'), DTOT(DATE()-5+nI))
NEXT
CREATE SQL VIEW Dt_view AS SELECT Dt_tab.key1, date_time, ;
TTOD(date_time) as datefield,;
SUBSTR(TTOC(date_time),10,2)+SUBSTR(TTOC(date_time),13,2)+ ;
SUBSTR(TTOC(date_time),16,2)+SUBSTR(TTOC(date_time),19,1) ;
as timefield FROM dt_dbc!dt_tab
* Datefield is a date field created from the date portion of date_time
* with the TTOD() function
*
* Timefield is a character field created from the time portion of
* date_time with concatenated SUBSTR()'s of the TTOC function with a
* format of HHMMSS(A or P).
=DBSETPROP('dt_view','view','SendUpdates',.T.)
&& Allows updates to be sent to table
* End Mktables.prg
Property Value Comment ------------------------------------------------------------------------ Form1.Width 400 Form1.Grid1.Width 370 Grid1.Column1.ReadOnly .T. Grid1.Column2.ReadOnly .T. Edited thru Columns 3 & 4 Grid1.Column1.Width 50 Grid1.Column2.Width 140 Grid1.Column3.Width 60 Grid1.Column4.Width 80 Grid1.Column4.Sparse .F. Shows mask in all rows Grid1.Column4.Text1.Format R! R = Input Mask, ! = Upper Grid1.Column4.Text1.InputMask 99:99:99 XM Displays like 10:25:15 AM Grid1.Column4.Text1.Margin 2 Text jumps if left at 0 Grid1.Column1.Header1.Caption Key1 Grid1.Column2.Header1.Caption Date_time Grid1.Column3.Header1.Caption Datefield Grid1.Column4.Header1.Caption Timefield
* This goes into the Valid for the text box that displays the date.
*
* This takes the date from the Datefield in Column3 and converts it
* to a string, concatenates it with time portion of the Date_time
* field, and converts the entire string back to a Datetime data type.
* Then it replaces the current value of the Date_time field with the new
* value.
REPLACE date_time WITH CTOT(DTOC(This.Value)+ ;
" "+SUBSTR(ALLTRIM(TTOC(date_time)),9))
* This goes into the Valid for the Text Box that displays the time.
*
IF !(SUBSTR(This.Value,7,1) $ "AP") && A or P must be entered for
&& the character before M
=MESSAGEBOX('Enter an "A" or "P"',0)
RETURN 0
ENDIF
* This takes the date from the Date_time field and converts it to a
* string, concatenates it with the Timefield character string in
* Column4, and converts the entire string back to a Datetime data
* type. Then it replaces the current value of the Date_time field with
* the new value.
REPLACE date_time WITH CTOT(SUBSTR(ALLTRIM(TTOC(date_time)),1,8)+ ;
" "+ SUBSTR(This.Value,1,2)+":"+SUBSTR(This.Value,3,2) + ;
":"+ SUBSTR(This.Value,5,2)+SUBSTR(This.Value,7,1)+'m')
Additional query words: VFoxWin
Keywords: kbcode KB138980