PDA

View Full Version : Please Assist


ABC123

Chris Donelon
04-10-2008, 12:51 PM
I am using A5V9

Could someone advise how to get a Trimester value from a Date()

Example: 01/01/2008 to 31/03/2008 = 1st Trimester

I have looked throughout the help files of A5V9

Thank you for your time

Chris Donelon

Steve Workings
04-10-2008, 12:59 PM
Here's one way.

Create a function like this:


FUNCTION Trimester AS N (vDate AS D )
MonthOfDate = month(vdate)
select
case between(MonthOfDate,1,3)
Trimester = 1
case between(MonthOfDate,4,6)
Trimester = 2
case between(MonthOfDate,7,9)
Trimester = 3
end select
END FUNCTION

Then call the function where/as needed. In interactive, for instance, you'd get this:


?trimester(date())
= 2
This function assumes that the current trimester starts on January 1. You may want to modify it to specify the starting date. But this'll get you started...

Stan Mathews
04-10-2008, 01:02 PM
If you just want this on one or two reports you can just create a calculated field with the expression


case(month(somedate)<4,"First Trimester",month(somedate)<7,"Second Trimester",month(somedate)<10,"Third Trimester",.t.,"Fourth Trimester")

But Steve's function is quite handy.

Chris Donelon
04-10-2008, 01:34 PM
Thanks to Steve & Stan for your assistance

Much appreciated

Chris Donelon

G Gabriel
04-10-2008, 02:33 PM
edited..
Timester as in Ist Trimester of preganancy? or as in school calendar?

MoGrace
04-10-2008, 02:37 PM
Hey Stan there are 12 months in the year... Nice function though for finding the Quarter!

Stan Mathews
04-10-2008, 02:39 PM
If you get to "Fourth Timester", Not sure what a "Timester" might be.

A trimester is a three month period, of which there are four (4) in a year. The last three month period of a year would be the "Fourth Trimester".


Trimester \Tri*mes"ter\, n. [L. trimestris of three months; tri- (see Tri-) + mensis month: cf. F. trimestre.]

A term or period of three months.

Source: Webster's Revised Unabridged Dictionary (1913)

G Gabriel
04-10-2008, 02:45 PM
Trimester... as in Ist trimester of pregnancy.
If you get to the fourth trimester, it's time to call a news conference!

MoGrace
04-10-2008, 03:02 PM
Trimester... as in Ist trimester of pregnancy.
If you get to the fourth trimester, it's time to call a news conference!heeheehee... I was thinking something like "semester" in relationship to school.

MikeC
04-10-2008, 06:10 PM
Robin,

Fooled me for a bit too until I thought about what the word "semester" really means....six months. But most think of it as coming from the prefix "semi-" meaning half and as a result it has taken on that meaning as well. So in that respect the word "Trimester" could very well take on a the secondary meaning that you at first thought. English language just gets more and more difficult to learn as meanings of words start to flow into each other at times...also makes it harder to be precise when such a dichotomy exists in a word's meaning.

MoGrace
04-11-2008, 12:52 AM
No Mike that wasn't it. I was thinking semi as in 1/2 and tri as in 1/3, therefore a trimester would be a period of 4 months - 1/3 of a year (vs 3 months as Stan pointed out). Sometimes I amaze myself that my brain works right at all! The context of pregnancy totally went by me. I should take a look at a dictionary before I post.