1

I created this script to do date calculation between a date and today, but for some reason I get a decimal number.

How can I just get the number of date without decimal point ?

Tried to use a roundup formula but that's messy, what the best way to handle this?

set theDateWantedValue to "25/03/2019"

set [dayVal, MonthVal, YearVal] to the words of theDateWantedValue
set the text item delimiters to "/"
##set date_string to {d, ordinal, Y} as text
##set myotherDate to date_string

set dateDelaybetwentheDate to ((date (theDateWantedValue as string)) - (current date)) / days


set myResultDateRound to RoundDecimal(dateDelaybetwentheDate, 1, down)

on RoundDecimal(NumberToRound, DecimalPlace, UpDown)
    set RoundFactor to 10 ^ DecimalPlace
    NumberToRound * RoundFactor
    round result rounding UpDown
    result / RoundFactor
end RoundDecimal

2 Answers 2

2

Maybe using a different approach will accomplish what you were looking for?

set someDate to "09/ 09 / 2019"
set theDate to date someDate
set currentDate to (current date)

set secondsBetweenDates to (theDate - currentDate)
set timeInDays to (secondsBetweenDates div days)
set timeInWeeks to (secondsBetweenDates div weeks)
set extraDays to (timeInDays mod timeInWeeks)


display dialog ((timeInWeeks as text) & " Weeks & " & extraDays & " Days Remaining Until " & someDate) ¬
    buttons {"Cancel", "OK"} default button "OK"

Obviously change the value of someDate to whatever you need

0

maybe adding " as integer" ? although that won't remove the negative sign

set dateDelaybetwentheDate to ((date (theDateWantedValue as string)) - (current date)) / days as integer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .