Solved

Access: Display Year and Quarter from Date field

Posted on 2009-05-08
4
622 Views
Last Modified: 2012-08-14
I want to know how I can display the year and quarter from a field that contains the date, example datefield. The format of the field is as follow: 4/30/2009  3:51:00 PM. I would like to create a table and have a field name "Year and Quarter" and display the data as 2009-Q2.
0
Comment
Question by:Unreal1998
[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
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 24337909
Try this:

SELECT DatePart("yyyy",[datefield]) & "-Q" & DatePart("q",[datefield]) AS YQ INTO TableYQ
FROM Table1;


mx
0
 
LVL 1

Expert Comment

by:mcfitz13
ID: 24342126
You can use the format tool

'Quarter
Format(Now,"q")

'Year
Format(Now,"yyyy")

Together
Format(Now,"yyyy") & "Q" &  Format(Now,"q")
0
 
LVL 44

Expert Comment

by:GRayL
ID: 24344148
How about Format(fldDate,"yyyy-\Qq")
0
 
LVL 44

Expert Comment

by:GRayL
ID: 24344162
More precisely:

SELECT fldDate, Format(fldDate,"yyyy-\Qq") AS [Year and Quarter] FROM myTable;
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

632 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