OK, I think I see what the problem is. I wanted to give them the option to have any time period on the fly so I added an "other" option:
on tUnitFG
put the date into myDate
convert myDate to dateItems
ask "How long before this item expires? (Ex: 1.25 (15 months), 1.5 (18 months), 1.75 (21 months), 2 (2 years), etc.)"
put it into sDateFG
put (sDateFG * 12) into item 2 of myDate
convert myDate to short date
put myDate into fld "exDate"
end tUnitFG
This is what doesn't work with .3 and such.
Any ideas?
adding a decimal amount to a date
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: adding a decimal amount to a date
OK,
use trunc or round eg:
Simon
use trunc or round eg:
Code: Select all
put round(sDateFG * 12) into item 2 of myDate
--or
put trunc(sDateFG * 12) into item 2 of myDate
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: adding a decimal amount to a date
Hi,
I just wanted to resolve this thread for the sake of anyone that has this same situation. I switched everything to months. I can have someone choose the number of months and store it in one of the fields and then add it to item 2 of dateItems. I did this on the arbitrary and on the fly versions below.
Thanks Simon and John, Great stuff!
on tUnitFG -- on the fly
put the date into myDate
convert myDate to dateItems
ask "How many months before this item expires? (Ex: 13 (1year 1 month), 24 (2 years), etc.)"
put it into sDateFG
add sDateFG to item 2 of myDate
convert myDate to short date
put myDate into fld "exDate"
end tUnitFG
on gramExp --arbitrary (value stored as preferences)
put the date into myDate
convert myDate to dateItems
add fld "setDateD" of cd "inventory1" of stack "inventory" to item 2 of myDate
convert myDate to short date
put myDate into fld "exDate"
end gramExp
I just wanted to resolve this thread for the sake of anyone that has this same situation. I switched everything to months. I can have someone choose the number of months and store it in one of the fields and then add it to item 2 of dateItems. I did this on the arbitrary and on the fly versions below.
Thanks Simon and John, Great stuff!
on tUnitFG -- on the fly
put the date into myDate
convert myDate to dateItems
ask "How many months before this item expires? (Ex: 13 (1year 1 month), 24 (2 years), etc.)"
put it into sDateFG
add sDateFG to item 2 of myDate
convert myDate to short date
put myDate into fld "exDate"
end tUnitFG
on gramExp --arbitrary (value stored as preferences)
put the date into myDate
convert myDate to dateItems
add fld "setDateD" of cd "inventory1" of stack "inventory" to item 2 of myDate
convert myDate to short date
put myDate into fld "exDate"
end gramExp
Re: adding a decimal amount to a date
(Devil's advocate here)...
What happens if the answer to
What happens if the answer to
is 3.1416?ask "How many months before this item expires? (Ex: 13 (1year 1 month), 24 (2 years), etc.)"
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: adding a decimal amount to a date
Mark,
I was biting my tongue on that question!
I put too much time in answering the OP
Simon
I was biting my tongue on that question!
I put too much time in answering the OP

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!