Upgrade from SQL Server 2008 to 2017 causes date subtraction error on Access front end form using DCount

Tom Bird

I inherited supporting a database from an employee that left the company years ago. The team that uses this is being forced to upgrade from SQL Server 2008 to SQL Server 2017.

Everything seems to work fine but there is a form that has text boxes that show some counts of the data using a DCount function. The problem kicks in when it is trying to subtract today's date (using Date()) from a column [DateReceived] (of type smalldatetime in SQL Server) from the table in the DCount function.

This works

=DCount("[ClaimNum]","tblClaimsData","[ClaimStatus] = 'Open' and  #2/4/2021# - [DateReceived] between 45 and 59")

This throws an error

=DCount("[ClaimNum]","tblClaimsData","[ClaimStatus] = 'Open' and Date() - [DateReceived] between 60 and 90")

I cannot seem to figure out a workaround for the Date() function IF that is where the problem is. I have a query that will count the data table but I cannot have a query as a control source for a text box, nor can I get a value of another text box in place of the Date() in my DCount function.

Any thoughts here? Thanks!

ODBC SQL subtraction error

Form with counts - the one that works has the date hard coded in the DCount function

Gustav

The error message is crystal clear. Your data type is now DateTime2, which the ODBC driver reads as text, causing any numeric date handling to fail.

Best option is to change the data type to DateTime and your code will work.

Else, convert the text dates to true dates:

=DCount("[ClaimNum]","tblClaimsData","[ClaimStatus] = 'Open' and Date() - DateValue([DateReceived]) between 60 and 90")

That may still fail, however, if the text dates contain milliseconds, like 2021-02-04 15:42:30.000.

If so, these must be chopped off before converting.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Move database from SQL Server 2012 to 2008

分類Dev

SSIS upgrade from 2008R2 to 2017 - script task fails when connecting to OLEDB data source

分類Dev

Create CLR stored procedure using the dll created by .net framework 4.0 in sql server 2008. Is shows error

分類Dev

SELECT query that Selects from Next Row given certain criteria using SQL Server 2008 R2?

分類Dev

Users on my network cant open the Sql server linked tables from their MS Access Form

分類Dev

Get error when rebuild index in sql server 2008

分類Dev

SQL Server 2008 Trigger

分類Dev

SQL Server 2008 SELECT

分類Dev

SQL Server 2008 - With 句

分類Dev

Heroku Error code=H27 desc="Client Request Interrupted" method=POST USING RAILS Server-side,Vue front-end

分類Dev

CONVERTING TO_DATE FROM ORACLE TO SQL SERVER

分類Dev

Error while writing data from Linux server to SQL Server using dbWriteTable

分類Dev

Pivot table in SQL Server 2008

分類Dev

Partitioned table - SQL Server 2008

分類Dev

Update to Openrowset SQL SERVER 2008

分類Dev

IBM WORKLIGHT SQL Server 2008

分類Dev

How to upgrade from VS 2017 to 2019?

分類Dev

Visual Studio 2017 Upgrade from Community to Enterprise

分類Dev

SUM from Specific Date until the end of the month SQL

分類Dev

Which are the causes to get END_TAG error?

分類Dev

How to get the week number, start date and end date of Compelete year in SQL Server?

分類Dev

Django form using choices against a queryset causes error if part of initial makemigrations

分類Dev

keep a node js function running without using any calls from front end

分類Dev

Showing Error in using case in sql server

分類Dev

MATLAB function from Java causes Runtime Error (EXCEPTION_ACCESS_VIOLATION)

分類Dev

Updating to EF 6.2.0 from EF 6.1.3 causes cannot access a disposed object error

分類Dev

Remove front and end white space from a string

分類Dev

How to set default value using alter table statement in sql server 2008

分類Dev

IIS PHP using Windows Authentication unable to connect to SQL Server 2008R2

Related 関連記事

  1. 1

    Move database from SQL Server 2012 to 2008

  2. 2

    SSIS upgrade from 2008R2 to 2017 - script task fails when connecting to OLEDB data source

  3. 3

    Create CLR stored procedure using the dll created by .net framework 4.0 in sql server 2008. Is shows error

  4. 4

    SELECT query that Selects from Next Row given certain criteria using SQL Server 2008 R2?

  5. 5

    Users on my network cant open the Sql server linked tables from their MS Access Form

  6. 6

    Get error when rebuild index in sql server 2008

  7. 7

    SQL Server 2008 Trigger

  8. 8

    SQL Server 2008 SELECT

  9. 9

    SQL Server 2008 - With 句

  10. 10

    Heroku Error code=H27 desc="Client Request Interrupted" method=POST USING RAILS Server-side,Vue front-end

  11. 11

    CONVERTING TO_DATE FROM ORACLE TO SQL SERVER

  12. 12

    Error while writing data from Linux server to SQL Server using dbWriteTable

  13. 13

    Pivot table in SQL Server 2008

  14. 14

    Partitioned table - SQL Server 2008

  15. 15

    Update to Openrowset SQL SERVER 2008

  16. 16

    IBM WORKLIGHT SQL Server 2008

  17. 17

    How to upgrade from VS 2017 to 2019?

  18. 18

    Visual Studio 2017 Upgrade from Community to Enterprise

  19. 19

    SUM from Specific Date until the end of the month SQL

  20. 20

    Which are the causes to get END_TAG error?

  21. 21

    How to get the week number, start date and end date of Compelete year in SQL Server?

  22. 22

    Django form using choices against a queryset causes error if part of initial makemigrations

  23. 23

    keep a node js function running without using any calls from front end

  24. 24

    Showing Error in using case in sql server

  25. 25

    MATLAB function from Java causes Runtime Error (EXCEPTION_ACCESS_VIOLATION)

  26. 26

    Updating to EF 6.2.0 from EF 6.1.3 causes cannot access a disposed object error

  27. 27

    Remove front and end white space from a string

  28. 28

    How to set default value using alter table statement in sql server 2008

  29. 29

    IIS PHP using Windows Authentication unable to connect to SQL Server 2008R2

ホットタグ

アーカイブ