Solved

Access: Display Year and Quarter from Date field

Posted on 2009-05-08
4
607 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

14 Experts available now in Live!

Get 1:1 Help Now