dbTalk Databases Forums  

FM5 - adding a year to a date, or several years

comp.databases.filemaker comp.databases.filemaker


Discuss FM5 - adding a year to a date, or several years in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sbitaxi@yorku.ca
 
Posts: n/a

Default FM5 - adding a year to a date, or several years - 07-04-2005 , 01:13 PM






I created a database for the office to track the details of the
employees, including start/hire dates. The HR Department wants to
project the anniversary dates of the employees and I did it using the
following calculation

If(DateofHire + 1915 <= Today,"Ten Year Anniversary: " &
(DateToText(DateofHire + 3650)),If(DateofHire + 1185 <= Today,"Five
Year Anniversary: "&(DateToText(DateofHire + 1825)),If(DateofHire + 450
<= Today,"Three Year Anniversary: " & (DateToText(DateofHire +
1095)),If(DateofHire + 90 <= Today,"One Year Anniversary: " &
(DateToText(DateofHire + 365)), "Probationary"))))

The anniversary dates are as follows
1 YR
3 YR
5 YR
10 YR

In order to display the projected anniversary date I had to add 365
days to the hire date or a multiple of 365 for the other years. The
challenge comes from the fact the there are not 365 days in every year
and an anniversary date should fall on the same date - 12/09/2000 to
12/09/2005. adding 365 days is inconsistent and changes the date.

Finally, my question - how do I change only the year and not the date?


Reply With Quote
  #2  
Old   
Matt Wills
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-04-2005 , 02:56 PM






Year3 = Date( Month(DateofHire), Day(DateofHire), Year(DateofHire) + 1)

Year3 = Date( Month(DateofHire), Day(DateofHire), Year(DateofHire) + 3)

and so on.

Matt

Copyright © 1994 - 2002 FileMaker, Inc. All Rights Reserved.

sbitaxi (AT) yorku (DOT) ca wrote:

Quote:
I created a database for the office to track the details of the
employees, including start/hire dates. The HR Department wants to
project the anniversary dates of the employees and I did it using the
following calculation

If(DateofHire + 1915 <= Today,"Ten Year Anniversary: " &
(DateToText(DateofHire + 3650)),If(DateofHire + 1185 <= Today,"Five
Year Anniversary: "&(DateToText(DateofHire + 1825)),If(DateofHire + 450
= Today,"Three Year Anniversary: " & (DateToText(DateofHire +
1095)),If(DateofHire + 90 <= Today,"One Year Anniversary: " &
(DateToText(DateofHire + 365)), "Probationary"))))

The anniversary dates are as follows
1 YR
3 YR
5 YR
10 YR

In order to display the projected anniversary date I had to add 365
days to the hire date or a multiple of 365 for the other years. The
challenge comes from the fact the there are not 365 days in every year
and an anniversary date should fall on the same date - 12/09/2000 to
12/09/2005. adding 365 days is inconsistent and changes the date.

Finally, my question - how do I change only the year and not the date?

Reply With Quote
  #3  
Old   
Matt Wills
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-04-2005 , 02:59 PM



Sorry, that first calc field name should be Year1

Matt Wills wrote:

Quote:
Year3 = Date( Month(DateofHire), Day(DateofHire), Year(DateofHire) + 1)

Year3 = Date( Month(DateofHire), Day(DateofHire), Year(DateofHire) + 3)

Reply With Quote
  #4  
Old   
ursus.kirk
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-05-2005 , 04:26 AM



You can split the DateOfHire into day, month and year (as numbers) and
re-use them.
cDay = day ( DateOfHire )
cMonth = month ( DateOfHire )
cYear = year ( DateOfHire )

Then add 1 (or whatever you need) to the year and put them back together as
date

cAnniversary = Date ( cMonth ; cDay ; cYear+1 )

If ( today = cAnniversary ; "HURRAY!" ; "Just wait...")

with FM7 use Get ( CurrentDate) instead of Today

<sbitaxi (AT) yorku (DOT) ca> schreef in bericht
news:1120500796.116354.68320 (AT) g47g2000cwa (DOT) googlegroups.com...
Quote:
I created a database for the office to track the details of the
employees, including start/hire dates. The HR Department wants to
project the anniversary dates of the employees and I did it using the
following calculation

If(DateofHire + 1915 <= Today,"Ten Year Anniversary: " &
(DateToText(DateofHire + 3650)),If(DateofHire + 1185 <= Today,"Five
Year Anniversary: "&(DateToText(DateofHire + 1825)),If(DateofHire + 450
= Today,"Three Year Anniversary: " & (DateToText(DateofHire +
1095)),If(DateofHire + 90 <= Today,"One Year Anniversary: " &
(DateToText(DateofHire + 365)), "Probationary"))))

The anniversary dates are as follows
1 YR
3 YR
5 YR
10 YR

In order to display the projected anniversary date I had to add 365
days to the hire date or a multiple of 365 for the other years. The
challenge comes from the fact the there are not 365 days in every year
and an anniversary date should fall on the same date - 12/09/2000 to
12/09/2005. adding 365 days is inconsistent and changes the date.

Finally, my question - how do I change only the year and not the date?




Reply With Quote
  #5  
Old   
Helpful Harry
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-05-2005 , 03:54 PM



In article <42ca5264$0$89655$dbd4b001 (AT) news (DOT) wanadoo.nl>, "ursus.kirk"
<secret (AT) nowhere (DOT) com> wrote:

Quote:
You can split the DateOfHire into day, month and year (as numbers) and
re-use them.
cDay = day ( DateOfHire )
cMonth = month ( DateOfHire )
cYear = year ( DateOfHire )

Then add 1 (or whatever you need) to the year and put them back together as
date

cAnniversary = Date ( cMonth ; cDay ; cYear+1 )

If ( today = cAnniversary ; "HURRAY!" ; "Just wait...")

with FM7 use Get ( CurrentDate) instead of Today
NEVER use Today.

Always use Status(CurrentDate) before FileMaker 7 and Get(CurrentDate)
with FileMaker 7.

Like Repeating Fields, the Today function is a left-over that should
really be removed. Today is only calculated ONCE when FileMaker is run,
so if running on a server (for example) or left running over-night the
Today function will give an incorrect date. (Obviously there are
occasionally times when knowing the "last started up date" is useful.)

The Status / Get(CurrentDate) function on the other hand is calculated
EVERY time it is used and so always gives the correct date.



Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #6  
Old   
Steven Bitaxi
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-05-2005 , 04:32 PM



Thanks Harry, I had no idea. Today is now yesterday.


S


Reply With Quote
  #7  
Old   
Steven Bitaxi
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-05-2005 , 04:38 PM



Just to be clear -

this will result in separate fields for each anniversary date, plus one
which will calculate the one that is coming up?

Admittedly, I want to do everything that I possibly can with one field,
but a couple extra won't really hurt me that much ; )


Reply With Quote
  #8  
Old   
Steven Bitaxi
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-05-2005 , 04:41 PM



that's easy. The only issue I see is the time frame around the
anniversary date, the only way that cAnniversary would display the next
coming date, is if it was already here.

Hence my really convoluted IF this then that so add something else and
say the alphabet backwards equation. Parsing out the date has great
potential.


S


Reply With Quote
  #9  
Old   
Steven Bitaxi
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-05-2005 , 04:43 PM



my "Just to be clear" reply is to Matt and the "that's easy" is to
ursus.kirk.

Thanks to everyone for their expertise. Someday, I may have an insight
to share with you too! ; )


S


Reply With Quote
  #10  
Old   
Matt Wills
 
Posts: n/a

Default Re: FM5 - adding a year to a date, or several years - 07-05-2005 , 05:49 PM





Steven Bitaxi wrote:

Quote:
Just to be clear -

this will result in separate fields for each anniversary date, plus one
which will calculate the one that is coming up?

Admittedly, I want to do everything that I possibly can with one field,
but a couple extra won't really hurt me that much ; )
This one seems to do everything in one field (calc is text):

Anniversary =

Case(
Status( CurrentDate) >= Date( Month(DateofHire), Day(DateofHire),
Year(DateofHire) + 10), "Tenth Anniversary: " & DateToText(Date(
Month(DateofHire), Day(DateofHire), Year(DateofHire) + 10)),
Status( CurrentDate) >= Date( Month(DateofHire), Day(DateofHire),
Year(DateofHire) + 5), "Fifth Anniversary: " & DateToText(Date(
Month(DateofHire), Day(DateofHire), Year(DateofHire) + 5)),
Status( CurrentDate) >= Date( Month(DateofHire), Day(DateofHire),
Year(DateofHire) + 3), "Third Anniversary: " & DateToText(Date(
Month(DateofHire), Day(DateofHire), Year(DateofHire) + 3)),
Status( CurrentDate) >= Date( Month(DateofHire), Day(DateofHire),
Year(DateofHire) + 1), "First Anniversary: " & DateToText(Date(
Month(DateofHire), Day(DateofHire), Year(DateofHire) + 1)),
"Probationary")

Matt


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.