Less than 1 Year

  • Thread starter Compiling and Confused
  • Start date
C

Compiling and Confused

I am writing an update query that calculates Years of Service (YOS) based off
of the start date. My current expression reads:

Int(DateDiff('d',([tbl_All_Employees].[Start Date]),Now())/365.25)

I would like it to show <1 if the result of the updated record is less than 1.
 
N

NTC

the < symbol may not be permitted if the field's table definition is a number

IIf(Int(DateDiff('d',([tbl_All_Employees].[Start
Date]),Now())/365.25)<1,"<1",Int(DateDiff('d',([tbl_All_Employees].[Start
Date]),Now())/365.25))
 
D

Duane Hookom

Your calculation isn't always correct. More correct methods can be found at
http://www.mvps.org/access/datetime/date0001.htm.

Since you suggest this is an "update query" can we assume:
1) you need to store a value that can be calculated
2) the field type is text since you can't store "<1" in a numeric field

If the field is numeric and stores the value zero, you can use the format
property of text boxes to display the value as "<1"
Format: 0.00;(0.00);"<0";"NA"
 
D

DK412

This was the perfect fix. The field definition is Text so it worked.

NTC said:
the < symbol may not be permitted if the field's table definition is a number

IIf(Int(DateDiff('d',([tbl_All_Employees].[Start
Date]),Now())/365.25)<1,"<1",Int(DateDiff('d',([tbl_All_Employees].[Start
Date]),Now())/365.25))



Compiling and Confused said:
I am writing an update query that calculates Years of Service (YOS) based off
of the start date. My current expression reads:

Int(DateDiff('d',([tbl_All_Employees].[Start Date]),Now())/365.25)

I would like it to show <1 if the result of the updated record is less than 1.
 

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

Top