Solved

Access: Display Year and Quarter from Date field

Posted on 2009-05-08
4
609 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
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
View vs Edit mode enhancements 12 40
Cross Tab with two column values 7 32
Sub Reports 8 21
Export Query data to excel file 14 26
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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.

932 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

13 Experts available now in Live!

Get 1:1 Help Now