Date calculations

G

Guest

Trying to get access to display the next quarter after a given date. For
example, date = 10/15/04, next quarter date to be displayed is 1/1/05 -
3/31/05. These are not calendar or fiscal quarters, only the first quarter,
second quarter, etc which occurs after date given. Date = 1/3/05 would
return value of the first quarter as 4/1/05 - 6/30/05.

Have tried various date functions, but can't get it.

Any help is appreciated.
 
A

Allen Browne

Next quarter starts:
DateSerial(Year(Date), 3 * (DatePart("q", Date) -1) + 4, 1)

To get the end, DateAdd() 3 months, and subtract 1.
 
J

John Vinson

Trying to get access to display the next quarter after a given date. For
example, date = 10/15/04, next quarter date to be displayed is 1/1/05 -
3/31/05. These are not calendar or fiscal quarters, only the first quarter,
second quarter, etc which occurs after date given. Date = 1/3/05 would
return value of the first quarter as 4/1/05 - 6/30/05.

Have tried various date functions, but can't get it.

Any help is appreciated.
Try:

= DateSerial(Year([GDate]), 3*(Month([GDate]) - 1) \ 3 + 3, 1) AND < DateSerial(Year([GDate]), 3*(Month([GDate]) - 1) \ 3 + 6, 1)

Alternatively, put a calculated field in your query:

DatePart("q", [datefield])

and use a criterion of

IIF(DatePart("q", [GDate]) = 4, 1, DatePart("q", [GDate]) + 1)


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
J

John Barnes

Thanks for the reply.
Two further questions?
1. Where does the "Year" come from in the first DateSerial?
2. Is the "Date" in the DateSerial and DatePart the user-
entered date (the date that I am trying to calculate from).
 
J

John Barnes

Thanks for the reply.

Two further questions.

1. Where does the Year and Month come from in your
solution? Is that a value I type in the formula, or a
part of the user-entered value?

2. Is Gdate the user-entered value that I am trying to
calculate on?


Thanks.
-----Original Message-----
Trying to get access to display the next quarter after a given date. For
example, date = 10/15/04, next quarter date to be displayed is 1/1/05 -
3/31/05. These are not calendar or fiscal quarters, only the first quarter,
second quarter, etc which occurs after date given. Date = 1/3/05 would
return value of the first quarter as 4/1/05 - 6/30/05.

Have tried various date functions, but can't get it.

Any help is appreciated.
Try:

= DateSerial(Year([GDate]), 3*(Month([GDate]) - 1) \ 3 +
3, 1) AND < DateSerial(Year([GDate]), 3*(Month([GDate]) -
1) \ 3 + 6, 1)
Alternatively, put a calculated field in your query:

DatePart("q", [datefield])

and use a criterion of

IIF(DatePart("q", [GDate]) = 4, 1, DatePart("q", [GDate]) + 1)


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
.
 
D

Douglas J. Steele

John's probably not up yet, so let me answer in his stead.

Year and Month are VBA functions that, respectively, extract the Year and
Month components from a given date.

GDate is the value on which you're trying to calculate.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


John Barnes said:
Thanks for the reply.

Two further questions.

1. Where does the Year and Month come from in your
solution? Is that a value I type in the formula, or a
part of the user-entered value?

2. Is Gdate the user-entered value that I am trying to
calculate on?


Thanks.
-----Original Message-----
Trying to get access to display the next quarter after a given date. For
example, date = 10/15/04, next quarter date to be displayed is 1/1/05 -
3/31/05. These are not calendar or fiscal quarters, only the first quarter,
second quarter, etc which occurs after date given. Date = 1/3/05 would
return value of the first quarter as 4/1/05 - 6/30/05.

Have tried various date functions, but can't get it.

Any help is appreciated.
Try:

= DateSerial(Year([GDate]), 3*(Month([GDate]) - 1) \ 3 +
3, 1) AND < DateSerial(Year([GDate]), 3*(Month([GDate]) -
1) \ 3 + 6, 1)
Alternatively, put a calculated field in your query:

DatePart("q", [datefield])

and use a criterion of

IIF(DatePart("q", [GDate]) = 4, 1, DatePart("q", [GDate]) + 1)


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dlookup 7
Calculation of Quarter 16
Quarterly Date Calc 1
Date calculations 11
Quarterly taxes query 2
Eligible date 5
Date Formulas for budget "burn rate" 4
Lookup with table 1

Top