Solved

Access - format date/time to date

Posted on 2013-05-31
5
981 Views
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.
0
Comment
Question by:patriotpacer
  • 3
  • 2
5 Comments
 
LVL 47

Accepted Solution

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

Author Comment

by:patriotpacer
ID: 39211964
Thx.

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

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.

Try:

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

Author Closing Comment

by:patriotpacer
ID: 39211998
Thx!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39212004
Welcome!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Some sers suddenly getting error popup msg 28 88
ACCESS 2010 - VBA - generic Table Open Button - Code 7 20
Calculation in Access 5 25
Mongo DB 18 41
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Read about achieving the basic levels of HRIS security in the workplace.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

776 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