Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2003, 01:56 AM
Registered User
 
Join Date: Jul 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datepart expression

Hi
I need to write an expression that will return the quarter and year from a field AGE_DATE.
In other words - if the date is 25 April 2003, it should return 02,2003
Can anyone help me.
Liz


 
Old August 12th, 2003, 04:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can't you just do
Code:
SELECT DatePart("q",[AGE_DATE]) & "," & Year([AGE_DATE]) AS QtrYr
FROM TableName;
 
Old August 12th, 2003, 07:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by pgtips
 Can't you just do
Code:
SELECT DatePart("q",[AGE_DATE]) & "," & Year([AGE_DATE]) AS QtrYr
FROM TableName;
Yes, but a word of caution when calculating quarters. Ask your financial dept. what your fiscal year is. The DATEPART function will give you quarters assuming Q1 = January to March, Q2 = April to June, Q3 = July to September, and Q4 = October to December. In my office, that would be incorrect. Our fiscal year is Q1 = October to December. In other offices, Q1 = July to September.

Whatever your quarter is, you need to offset the number the DATEPART gives you and make a note of it in your code.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
DatePart Calculations ninel SQL Language 2 February 29th, 2008 03:08 AM
Datepart Vision G Access 2 October 18th, 2006 06:56 AM
CHapter 4 - using DatePart in query vgebha03 BOOK: Beginning Access VBA 0 June 2nd, 2005 02:48 PM
Using Datepart to get half an hour precision venomm Access 2 March 16th, 2005 10:08 AM
DatePart pab006 Classic ASP Basics 1 July 8th, 2004 12:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.