Solved

MS ACCESS text date field compared in CRITERIA as NOT this Year

Posted on 2013-11-14
5
394 Views
Last Modified: 2013-11-14
PREVIOUS QUESTION

As a follow on to the above question I need to also check that something is NOT THIS YEAR, I've tried taking the lead from the above question where criteria MONTH(DATE()) allowed for a comparison of this month against the data and looking at something like NOT YEAR(DATE()) but this didn't work.

This bit does provide the year:
SVC_YEAR: Year(Format(Mid([SVC_DATE],5,2) & "/" & Mid([SVC_DATE],7,2) & "/" & Left([SVC_DATE],4),"mm/dd/yyyy"))
0
Comment
Question by:ghettocounselor
5 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 250 total points
ID: 39648643
in the SVC_YEAR column, place in the criteria row


<>Year(date())
0
 

Author Comment

by:ghettocounselor
ID: 39648653
with this I get "DATA TYPE MISMATCH IN CRITERIA EXPRESSION"

WHERE (((Year(Format(Mid([SVC_DATE],5,2) & "/" & Mid([SVC_DATE],7,2) & "/" & Left([SVC_DATE],4),"mm/dd/yyyy")))<>Year(Date())));
0
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 250 total points
ID: 39648662
You coudl simplify the calculated column (field) to:

SVC_YEAR: Val(Left([SVC_DATE],4)) 

Open in new window

then use the criteria

<>Year(date())

or edit the where clause to include:

Where  Val(Left([SVC_DATE],4)) <>  YEAR(DATE()) ...

Open in new window

0
 
LVL 61

Expert Comment

by:mbizup
ID: 39648665
Try  simplifying it like this (adding the xxxx to the end handles nulls):

SVC_YEAR: Left(SVC_DATE & "xxxx",4)  

And use as criteria (as cap1 suggested):  <> Year(Date())
0
 

Author Closing Comment

by:ghettocounselor
ID: 39648725
Thanks for all the help
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
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.

757 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

22 Experts available now in Live!

Get 1:1 Help Now