CONVERT function gets date from SQL Server DateTime field with a Visual FoxPro query (308133)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Windows 6.0
- Microsoft Visual FoxPro for Windows 7.0
- Microsoft Visual FoxPro 8.0
- Microsoft Visual FoxPro 9.0 Professional Edition
This article was previously published under Q308133 SUMMARY
Dates that are stored in a SQL Server table are stored as a DateTime data type. You can use the SQL Server CONVERT() function to extract the date portion of a SQL DateTime field with a Visual FoxPro query; for example:
SELECT CONVERT(CHAR(10), <field name>, 101) FROM <table name>
You can still supply just the date when specifying a filter condition in the query. The time is not required in the expression. For example:
SELECT CONVERT(CHAR(10), <field name>, 101) FROM <table name> ;
WHERE <field name> = '01-01-1999'
The first and third parameters in the function call above (CHAR(10) and 101) are specific to extracting Date from DateTime. The SQL Server Books Online topic for the CONVERT function describes other available options.
REFERENCES
For additional information about the SQL CONVERT function, see SQL Server Books Online.
Modification Type: | Major | Last Reviewed: | 2/2/2005 |
---|
Keywords: | kbCodeSnippet kbDatabase kbinfo KB308133 kbAudDeveloper |
---|
|