Microsoft KB Archive/130346

= How to Manipulate DateTime Fields in a Browse =

Article ID: 130346

Article Last Modified on 8/26/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q130346



SUMMARY
Microsoft Visual FoxPro introduces a new data type, DateTime, that allows a date and time value to be stored in a single field. By default, Visual FoxPro displays the data stored to DateTime fields in a MM/DD/YY HH:MM:SS XM format. This article describes how to display just the date or just the time portion of a DateTime field in a Browse window.



MORE INFORMATION
Visual FoxPro does not offer a command or function that automatically retrieves just the Date or just the Time portion of a DateTime field. The code provided below creates two functions GETDATE and GETTIME. The BROWSE command will use those functions to display just the date and just the time of a Datetime field.

Code Sample
*
 * Begin Program
 * This program assumes a table already exists with a DateTime field named
 * tField.
 * tField.

BROWSE FIELDS date=getdate(tField), time=gettime(tField)


 * The BROWSE command passes tField to the functions getdate
 * and gettime. Each function returns to the BROWSE the values of
 * justdate and justtime.
 * justdate and justtime.

FUNCTION getdate PARAMETERS tField justdate = SUBSTR(TTOC(tField),1,8) RETURN justdate ENDFUNC

FUNCTION gettime PARAMETERS tField justtime = SUBSTR(TTOC(tField),10) RETURN justtime ENDFUNC


 * NOTE: The justdate and justtime fields will be read-only at run time.
 * End Program
 * End Program

Additional query words: VFoxWin

Keywords: kbcode KB130346

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.