Solved

Current Year in Query

Posted on 2014-01-20
5
440 Views
Last Modified: 2014-01-20
I am using  a WHERE clause that properly pulls up the current week in a query. I would like a separate query to pull up current year's data. How can I change this code to be current year?

WHERE Format(Nz([qryStatsforDailySalesReport].[DateField],#1/1/1950#),"wwyy") = Format(Now(),"wwyy")
0
Comment
Question by:cansevin
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39794190
Here you go:
WHERE Year(Nz([qryStatsforDailySalesReport].[DateField],#1/1/1950#) = Year(Date())

Open in new window

0
 
LVL 6

Accepted Solution

by:
Mahesh Bhutkar earned 500 total points
ID: 39794209
you can try out,
WHERE Format(Nz([qryStatsforDailySalesReport].[DateField],#1/1/1950#),"yyyy") = Format(Now(),"yyyy")
0
 

Author Comment

by:cansevin
ID: 39794215
Unfortunately that one didn't work. Any idea what could be wrong?
0
 

Author Closing Comment

by:cansevin
ID: 39794217
Thanks!
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39794237
I forgot a parenthesis, that's why it didn't work:
WHERE Year(Nz([qryStatsforDailySalesReport].[DateField],#1/1/1950#)) = Year(Date())

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

860 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