MS ACCESS text date field compared with datereltoday in query

Posted on 2013-11-14
Last Modified: 2013-11-14
I have a field SVC_DATE stored as text in this format 20131114
and what I want to do is use a criteria of 'this month' as in current month based on todays date.

I am able to get the month out of the thing with this
SVC_MONTH: Month(Format(Mid([SVC_DATE],5,2) & "/" & Mid([SVC_DATE],7,2) & "/" & Left([SVC_DATE],4),"mm/dd/yyyy"))

And I'm having trouble with setting up the criteria of 'this month'.

I was thinking something like "Like Month(DATERELTODAY(0))" but get a data type mismatch

Question by:ghettocounselor
  • 2
LVL 61

Accepted Solution

mbizup earned 500 total points
ID: 39648581
This month would simply be:


Is that what you are looking for?
LVL 61

Expert Comment

ID: 39648591
Based on your expression, I think you would  just need:

SVC_MONTH: Month(Format(Mid([SVC_DATE],5,2) & "/" & Mid([SVC_DATE],7,2) & "/" & Left([SVC_DATE],4),"mm/dd/yyyy"))

And set the criteria

= Month(Date())

Author Closing Comment

ID: 39648596
Works as advertised.
Appreciate the quick reply.
LVL 39

Expert Comment

ID: 39648598
You can use DateSerial(Y,M,D) for conversion if you like to use date functions:
DateSerial(Left([SVC_DATE],4), Mid([SVC_DATE],5,2), Mid([SVC_DATE],7,2))
but in you case month is equal to Mid([SVC_DATE],7,2)
should be enough

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now