Access - format date/time to date

Posted on 2013-05-31
Last Modified: 2013-05-31
I'm trying to do a query to remove the time aspect so that it just looks at the date alone.

and last_contact < format(now(), 'mm/dd/yy)-2

Open in new window

How do I fix this?  I wanna go back 2 days on the date by itself, not including the time.

last_contact is a date/time field.
Question by:patriotpacer
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
  • 3
  • 2
LVL 48

Accepted Solution

Dale Fye (Access MVP) earned 500 total points
ID: 39211962
AND DateValue([last_contact]) < DateAdd("d", -2, date())

Author Comment

ID: 39211964

Anything I need to change to put this in SQL?  I'm getting a data type mismatch error.
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 39211996
I assumed that the syntax in your original post was a part of a SQL string WHERE clause.

If you are getting a data type error, then it is likely that [last_contact] is a string, not a date.


And datevalue(cdate([last_contact])) < dateadd("d", -2, date())

Author Closing Comment

ID: 39211998
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 39212004

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

705 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