Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# firstweekofyear in access 2010

Posted on 2012-03-22
Medium Priority
306 Views
How do you use the constant firstweekofyear in access 2010 DateDiff function?
I am trying to filter if a date result is in previous year, current year or null
0
Question by:simernet
[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
• 4
• 3

LVL 52

Expert Comment

ID: 37753864
That for week calculations, it won't tell you about the year.

Use Year for that:

intYearOfDate = Year(datYourDate)
If intYearOfDate = Year(Date()) Then ' this year.
If intYearOfDate = Year(Date()) - 1 Then ' last year.
Else ' other year.

/gustav
0

LVL 35

Expert Comment

ID: 37753904
Not sure what constant you mean.

Anyway you don't need a constant for this, you could use Date /Year in an expression like this.

Switch(IsNull([DateField]), "Null", Year([DateField]) = Year(Date()), "This Year", Year([DateField]) = Year(Date())-1, "last Year")
0

LVL 1

Author Comment

ID: 37754051
In english I am looking to see if a date occured anytime in the current year or if it falls anytime withing the previous year.  I also want to know if it is null.
I have the Null part IsNull([disenrollDate])
0

LVL 35

Expert Comment

ID: 37754063
The expression I posted does that and returns a string indicating if its null, in the current year or form last year.

What do you want have returned?
0

LVL 1

Author Comment

ID: 37754166
I want this as a filter, so True or False.
I am looking for
True,  IsNull,
True,  This year
True, Last calendar year  ex. (01 JAN 2011  -  31 DEC 2011)
False if any year prior.

Cannot hard code in dates as it will float from year to year.
0

LVL 35

Accepted Solution

Norie earned 2000 total points
ID: 37754248
What I posted didn't hardcode anything.

Anyway, just use this in the criteria for the filter.

Not IsNull([disenrollDate]) AND (Year([isenrollDate]) = Year(Date()) OR [disenrollDate]= Year(Date())-1

The Year functions returns the year of a date and Date returns the current date.

So today Year(Date()) returns 2012  but on this day next year will return 2013 and so on.
0

LVL 1

Author Comment

ID: 37754347
Year([DisenrollDate])=Year(Date())-1 Or Year([DisenrollDate])=Year(Date()) Or IsNull([DisenrollDate])=True

Thanks,
0

LVL 35

Expert Comment

ID: 37754435
Oops, don't know where that AND came from.
0

## Featured Post

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…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
###### Suggested Courses
Course of the Month11 days, 11 hours left to enroll