Solved

Current Year in Query

Posted on 2014-01-20
5
433 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
Comment Utility
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
Comment Utility
you can try out,
WHERE Format(Nz([qryStatsforDailySalesReport].[DateField],#1/1/1950#),"yyyy") = Format(Now(),"yyyy")
0
 

Author Comment

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

Author Closing Comment

by:cansevin
Comment Utility
Thanks!
0
 
LVL 29

Expert Comment

by:IrogSinta
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

11 Experts available now in Live!

Get 1:1 Help Now