Microsoft KB Archive/299695

= FIX: You may receive an &quot;Ambiguous date/datetime constant&quot; error message when you create a view that contains a WHERE clause in Visual FoxPro 6.0 =

Article ID: 299695

Article Last Modified on 3/17/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q299695





SYMPTOMS
If you create a view that contains a WHERE clause in Microsoft Visual FoxPro 6.0, and the WHERE clause uses a date in the format {^yyyy-mm-dd}, you may receive the following error message:

Ambiguous date/datetime constant. Use the format:

{^yyyy-mm-dd[,][hh[:mm[:ss]] [a|p]]}



RESOLUTION
To resolve this problem, upgrade to the latest version of Microsoft Visual FoxPro. For more information, visit the following Microsoft Developer Network Web site:

http://msdn.microsoft.com/vfoxpro



STATUS
This problem was corrected in Visual FoxPro version 7.0 for Microsoft Windows.



Steps to reproduce the problem
  In Visual FoxPro 6.0, save the following code sample as a program. *!* SET STRICTDATE TO 1
 * 1) DEFINE DBCNAME 'testdb'
 * 2) DEFINE TABNAME 'testtab'
 * 3) DEFINE TABCOUNT 1

CLEAR CLOSE DATABASES ALL DELETE FILE testdb.DBC DELETE FILE testdb.dc?

CREATE DATABASE DBCNAME

FOR lni = 1 TO TABCOUNT DELETE FILE (TABNAME+ALLTR(STR(lni)))+'.dbf' DELETE FILE (TABNAME+ALLTR(STR(lni)))+'.cdx' CREATE TABLE (TABNAME+ALLTR(STR(lni))) (F1 C(10) NOT NULL ;       PRIMARY KEY, F2 d NOT NULL) ENDFOR

USE testtab1 FOR lni = 1 TO 3 INSERT INTO testtab1 (F1, F2) VALUES ('Number '+ALLTR(STR(lni)), DATE+lni-1) ENDFOR

CREATE SQL VIEW vtesttab1 AS SELECT * FROM testtab1 WHERE F2 = ?dDate DBSETPROP('VTESTTAB1', 'View', 'UpdateType', 1) DBSETPROP('VTESTTAB1', 'View', 'WhereType', 1) DBSETPROP('VTESTTAB1', 'View', 'SendUpdates', .T.) DBSETPROP('VTESTTAB1', 'View', 'Tables', 'testdb!testtab1') DBSETPROP('VTESTTAB1.f1', 'Field', 'KeyField', .T.) DBSETPROP('VTESTTAB1.f1', 'Field', 'Updatable', .T.) DBSETPROP('VTESTTAB1.f1', 'Field', 'UpdateName', 'testdb!testtab1.f1') DBSETPROP('VTESTTAB1.f1', 'Field', 'DataType', &quot;C(10)&quot;)

DBSETPROP('VTESTTAB1.f2', 'Field', 'KeyField', .F.) DBSETPROP('VTESTTAB1.f2', 'Field', 'Updatable', .T.) DBSETPROP('VTESTTAB1.f2', 'Field', 'UpdateName', 'testdb!testtab1.f2') DBSETPROP('VTESTTAB1.f2', 'Field', 'DataType', &quot;d&quot;) DBSETPROP('VTESTTAB1', 'View', 'ParameterList', &quot;dDate,'D'&quot;)

cDate = &quot;{^&quot;+TRANS(YEAR(DATE))+&quot;-&quot;+TRANS(MONTH(DATE))+&quot;-&quot;+TRANS(DAY(DATE))+&quot;}&quot; ?cDate

lcFails = .T. && Change this to .F. for it to work correctly. IF lcFails _CLIPTEXT = cDate && This fails. ELSE dDate = &cDate && This works. ENDIF

USE vtesttab1 BROWSE NOWAIT  Run the program that you created in step 1. When the View Parameter dialog box appears, press CTRL+V to paste in the date that is saved in the clipboard.

Additional query words: Visual Studio 7 109269

Keywords: kbbug kbfix kbxbase kbcodesnippet kbvfp700fix KB299695

-

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

© Microsoft Corporation. All rights reserved.