[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Querying SQL Server 2014 ‘date and ‘datetime’ fields from Access 2013

Posted on 2016-07-19
2
Medium Priority
?
98 Views
Last Modified: 2016-07-19
I have years of experience developing Access application with Access backend DB’s.   I am now working on an Access 2013 application with a SQL Server backend.

I am implementing a ‘filter’ form that I have created dozens of times in prior Access apps.  There are unbound fields at the top of a continuous form.  Whatever the user enters in the unbound fields is used to filter the records shown on the bound part of the continuous form.  They look like this:

Example Of Filter Screen
The filter form is working correctly on numeric and text fields but I am having issues filtering dates.

Using degug.print I verified that the SQL generated from the form is correct.  This is the generated SQL:

Select * From dbo_vtblEvents Where  [EventDate] >= #1/10/2005# And [EventDate] <=  #1/30/2005#


I also verified that there is data in the view within the dates specified.

I get zero records on the screen when the query is used as the recordsource of the form.

In the base table ‘EventDate’ is defined as data type ‘date’

I have the view ‘dbo_vtblEvents’ linked to my Access app.  When I bring up the view in the table designer, field ‘EventDate’ shows as data type short text.

Event date also shows on the screen as ‘2005-10-10’ instead of “1/10/2005”.

I’m getting the feeling that querying/filtering and even displaying SQL dates is not as straightforward as filtering Access dates.

Does anyone have insight into querying SQL Server dates form an Access application?  How do I get the dates to show on the screen in standard ‘1/10/15’ format rather than ‘2005-01-10’?
 
Any help would be appreciated.
0
Comment
Question by:mlcktmguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 2000 total points
ID: 41719995
Access hasn't kept up with SQL Server. It does not recognise the Date datatype in SQL Server as a Date value (nor does it recognise DateTime2).

If you look at your linked tables, you'll see that it treats it as a text datatype (the default for everything it cannot resolve).

Try using
CDate([EventDate]) >= #1/10/2005# to make Access try and treat the value as a date - you may have to watch out for where the day, month, year is in the string).

Kelvin
0
 
LVL 1

Author Closing Comment

by:mlcktmguy
ID: 41720108
Thanks for the heads up.  After I posted the question I noticed that the date filters worked OK on the fields defined as date time.  Just the 'date' fields were the issue.

Even though EventDate only  contains a date and no time, I revised the definition in the base SQL table to datetime.  The lookup is working as expected now.

I'll stay away from using the 'date' data type in any of the table defs.

Thanks again.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question