Obtain quarterly records in Access with the DatePart function
Takeaway: How did your company's stock fare last quarter? Who came aboard during the first quarter last year? Mary Ann Richardson shows how to use the DatePart function in Access to obtain quarterly results.
IT managers often want to know data points about a particular quarter. If you need to retrieve this information, you can use a Between expression in a query's Criteria field to find all Access records between a range of dates, such as Between #4/1/2005# and #6/30/2005#. Another alternative is to use the DatePart expression, which lets you find all records for a quarter.
Let's say you need to obtain a listing of all employees who were hired the second quarter of 2005. To obtain the answer using the DatePart function, follow these steps:
- Open the Employees database and click Queries under Objects in the Database Windows.
- Click New and then OK.
- Select the Employees table from the list, and then click Add.
- Double-click the Employee ID, First Name, and Last Name fields from the Employees table field list.
- Click in the next blank field cell and enter the following
expression:
Quarter: DatePart("q",[Hire Date]) - Enter 2 in the Quarter field's criteria cell.
- Click
in the next blank field cell and enter the following expression:
Year: Year([Hire Date]) - Enter 2005 in the Year field's Criteria cell. Then, simply save and run your query.
You can also use the DatePart and Year expressions in a parameter query and allow users to enter the quarter and year themselves.
Miss a tip?
Check out the Microsoft Access archive, and catch up on our most recent Access tips.
Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- Disaster Recovery Simplified: iSCSI and VMware Site Recovery Manager Deliver Results Dell EqualLogic
- Virtualized iSCSI SANs: Flexible, Scalable, Enterprise Storage for Virtual Infrastructures Dell EqualLogic
- Simple, Affordable Disaster Recovery Automation in the Virtualized IT Datacenter Dell EqualLogic
- Live Webcast: Enterprise Search Architectures of the Future Google
- Virtualization and Disk Performance Diskeeper
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET

