If the database is MSSQL, if only the time or date is inserted, the database inserts the complete date and time format by default, in this way, all the date and time are displayed by default when you use the data sensing control to display the time. However, sometimes you only want to display the date or only the time, but the default display format obviously does not meet the requirements.
So how can we make the data-aware control show only the date or only the time? In fact, you can set the dispalyformat format of the data source of the data sensing control to achieve this goal.
Assume that a time data is displayed using the adoconnection, adoquery, datasource, and DBGrid controls. Set the connection between adoconnection and the database, write the SQL statement of adoquery, and set the relationship between the four. The result is as follows:
However, this is obviously not the expected result, but only the time is displayed.
You can set the displayformat of the data source field. The specific method is as follows:
1. Right-click the data source control and select "fields Editor"
2. In the open editor window, select "add all fields" to select all fields or "add fields" to select the fields to be displayed.
3. Select the selected field and write the time display format in "displayformat" in the attribute bar.
4. Now, the settings are complete. Run the program again. The following page is displayed.
This is exactly what you want to achieve.