473,396 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Quarter to Date conversion

Hello,
I am relatively new to Microsoft Access and databases in general, and
have a problem - one which I think may necessitate some VBA code (or
maybe just modification of the criteria section of the query.
I have a table with several columns being imported into a query which
will eventually be used in a report. One of the fields in the
database is called 'Predicted Completion Date' and is in the format:
Q# Year (formatted as text). Some examples are: Q1 2003, Q4 2007, Q3
2004 etc. Now I need to compare this date with another date, in
"normal" date format which comes from another table, but will be
located in the same query. What I'm needing to do is to convert the Q#
part to a date, and then tack on the year to it. What I'm hoping to do
is make:
Q1 = January 1
Q2 = April 1
Q3 = July 1
Q4 = October 1
and then add on whatever the year is to the end.
For example, Q2 2006 = April 1 2006
Would anyone know how I would go about accomplishing this?

Thank you!
-r.s.
Dec 13 '07 #1
2 5388
The month is:
3 * (Val(Nz(Mid([Predicted Completion Date],2,1),"")) - 1) + 1

The year is:
Nz(Right([Predicted Completion Date],4), 1900)

The date is therefore something like this (one line):
DateSerial(Nz(Right([Predicted Completion Date],4), 1900),
3 * (Val(Nz(Mid([Predicted Completion Date],2,1),"")) - 1) + 1,
1)

It would probably be easier and more efficient to store the quarter as a
date rather than text.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<p.********@gmail.comwrote in message
news:d7**********************************@e6g2000p rf.googlegroups.com...
Hello,
I am relatively new to Microsoft Access and databases in general, and
have a problem - one which I think may necessitate some VBA code (or
maybe just modification of the criteria section of the query.
I have a table with several columns being imported into a query which
will eventually be used in a report. One of the fields in the
database is called 'Predicted Completion Date' and is in the format:
Q# Year (formatted as text). Some examples are: Q1 2003, Q4 2007, Q3
2004 etc. Now I need to compare this date with another date, in
"normal" date format which comes from another table, but will be
located in the same query. What I'm needing to do is to convert the Q#
part to a date, and then tack on the year to it. What I'm hoping to do
is make:
Q1 = January 1
Q2 = April 1
Q3 = July 1
Q4 = October 1
and then add on whatever the year is to the end.
For example, Q2 2006 = April 1 2006
Would anyone know how I would go about accomplishing this?

Thank you!
-r.s.
Dec 13 '07 #2
p.********@gmail.com wrote in
news:d77231e9-d736-4a3b-b00e-5a0f52814e85
@e6g2000prf.googlegroups.com
:
Hello,
I am relatively new to Microsoft Access and databases in general,
and have a problem - one which I think may necessitate some VBA
code (or maybe just modification of the criteria section of the
query. I have a table with several columns being imported into a
query which will eventually be used in a report. One of the
fields in the database is called 'Predicted Completion Date' and
is in the format: Q# Year (formatted as text). Some examples are:
Q1 2003, Q4 2007, Q3 2004 etc. Now I need to compare this date
with another date, in "normal" date format which comes from
another table, but will be located in the same query. What I'm
needing to do is to convert the Q# part to a date, and then tack
on the year to it. What I'm hoping to do is make:
Q1 = January 1
Q2 = April 1
Q3 = July 1
Q4 = October 1
and then add on whatever the year is to the end.
For example, Q2 2006 = April 1 2006
Would anyone know how I would go about accomplishing this?

Thank you!
-r.s.
It would be much simpler to do the conversion the other way, in that

"Q" & datepart("q", somedate) & " " & datepart("yyyy",somedate)

will return the proper string for comparison, but if you cannot
compare that way, you can try

dateSerial(mid(quarterfield,4,4),((val(mid(quarter field,2,1)-1)*3)+
1,1)

All on one line

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt | last post by:
Hello, I have a query that I would like to schedule in DTS. The criteria of this query checks for records in the table that are within the current quarter. Here is what I have. WHERE...
1
by: Terencetrent | last post by:
I have created a query that examines qarterly sales for 5 regions in the country. The query contains data for the past 6 quarters for each region and calculates the perecentage of total sales for...
8
by: Dominique Vandensteen | last post by:
I have a datetime and want to format it to "quarter year" so 20 december 2003 should give: "4-2003" is this possible? I don't find a format character for quarter :-( Dominique
3
by: RD | last post by:
Say Company's financial year starts October First and say we are now March 17th. How do you determine which quarter of the Financial year - not the actual year - March 17th is in. Thanks for any...
2
by: JohnC | last post by:
This fantastic expression was posted by Duane Hookom. I have no idea how it works but it displays the fiscal year and quarter for FY starting on October 1. =Format$(DateAdd("q",1,),"\Qq...
1
by: mnoland | last post by:
I relay need some help I am looking to find every quarter between 2 dates here is an example of what i am trying to do data table client sbegin send 499 1-1-2000 6-1-2001...
6
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
All, I try to get specific date's quarter value, for eaxmple quarter value is 1 for 02/04/2008, anyone can help this out? Thanks Martin
2
benchpolo
by: benchpolo | last post by:
First Day of the QUARTER select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0) Question: How do I get the last DAY of the QUARTER? For example: 1st Quarter is 01/01/2008 to 03/31/2008. I am...
4
by: gimme_this_gimme_that | last post by:
Is there a way to get the last day of the previous business quarter from DB2? For 10/21/2008 the day would be 9/30/2008. Thanks.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.