Microsoft Knowledge Base Email Alertz

KBAlertz.com: If you create a view with a WHERE clause that uses a date in the following 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]]}

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **


Community Site



We Send hundreds of thousands of emails using ASP.NET Email


ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 299695 - Last Review: March 17, 2005 - Revision: 2.0

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

This article was previously published under Q299695

On This Page

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 (http://msdn.microsoft.com/vfoxpro)

STATUS

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

MORE INFORMATION

Steps to reproduce the problem

  1. In Visual FoxPro 6.0, save the following code sample as a program.
    *!*
    SET STRICTDATE TO 1
    #DEFINE DBCNAME 'testdb'
    #DEFINE TABNAME 'testtab'
    #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', "C(10)")
    
    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', "d")
    DBSETPROP('VTESTTAB1', 'View', 'ParameterList', "dDate,'D'")
    
    cDate = "{^"+TRANS(YEAR(DATE()))+"-"+TRANS(MONTH(DATE()))+"-"+TRANS(DAY(DATE()))+"}"
    ?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
    					
  2. 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.

APPLIES TO
  • Microsoft Visual FoxPro 6.0 Professional Edition
Keywords: 
kbbug kbcodesnippet kbfix kbvfp700fix kbxbase KB299695
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please