If statement (1 Viewer)

Sham

Registered User.
Local time
Today, 19:51
Joined
May 31, 2007
Messages
11
Hi,

Is there anyone here who can help me with writing a formula in query to return results.
Basically i have hire and rehire columns and i want my new column to have a formula to give me the most recent hire/rehire date.

Please respond if u can help
thx
 

KeithG

AWF VIP
Local time
Today, 11:51
Joined
Mar 23, 2006
Messages
2,592
IIF([HireDate]>[ReHireDate],[HireDate],[ReHireDate])


the above should return the greater of the two dates
 

rainman89

I cant find the any key..
Local time
Today, 14:51
Joined
Feb 12, 2007
Messages
3,015
i believe if u search the dmax function you will find your answer
 

KeithG

AWF VIP
Local time
Today, 11:51
Joined
Mar 23, 2006
Messages
2,592
i believe if u search the dmax function you will find your answer

I believe these are two different elements in the same record.
 

Sham

Registered User.
Local time
Today, 19:51
Joined
May 31, 2007
Messages
11
thanks Keith, however i get 'data type mismatch in criteria expression' error
i have pasted in your formula (after amending the column headings) into the field column of my query.

not sure where i've gone wrong?!
 

KeithG

AWF VIP
Local time
Today, 11:51
Joined
Mar 23, 2006
Messages
2,592
Sounds like you fields are not of the same data type, are they?
 

Sham

Registered User.
Local time
Today, 19:51
Joined
May 31, 2007
Messages
11
its working! thx Keith
now my next q
what is the formula to get the length of service between dates in yy-mm format
i.e 01/01/2006 - 31/05/2007
 

Sham

Registered User.
Local time
Today, 19:51
Joined
May 31, 2007
Messages
11
yes i want the results to show in years and months
 

Ripley

Registered User.
Local time
Today, 19:51
Joined
Aug 4, 2006
Messages
148
create two colums called YearPart and MonthPart.

In the year part type:

YearPart1: DatePart("yyyy", [YOUR FIELD NAME])

In the month part type:

MonthPart1: DatePart("m", [YOUR FIELD NAME])

Duplicate this for the other field so you get the year and month part from it, and call the fields YearPart2 and MonthPart2

Then create a new field called YearMonth and type:

YearMonth: "Year: " & ([YearPart1] - [YearPart2]) & " Month: " ([MonthPart1] - [MonthPart2])

That should be about right, just have a play around with it.
 

Sham

Registered User.
Local time
Today, 19:51
Joined
May 31, 2007
Messages
11
hi ripley, when i enter my field name it becomes a parameter
 

Users who are viewing this thread

Top Bottom