Original date:2016-12-06 13:23:40 Edited by: petelomax Subject: Re: DaysBetweenDates - the easy way with Euphoria 4.0+

For comparison, this is what that looks like in Phix:
add/uncomment at the bottom of builtins\timedate.e

global function timedate_diff(timedate td1, timedate td2) 
    return timedate_to_seconds(td2)-timedate_to_seconds(td1) 
end function 

test code (same output):

include builtins/timedate.e 
set_timedate_formats({"DD/MM/YYYY","Dddd, Mmmm dd yyyy"},2) 
constant BIRTH_DATE = parse_date_string("28/6/1950") 
constant DATE2 = date() 
constant secs = timedate_diff(BIRTH_DATE, DATE2) 
constant days = floor(secs/(24*60*60)) 
constant d3 = adjust_timedate(BIRTH_DATE, secs) 
printf(1, "There are %d days between %s and %s. \n\n",   
printf(1, "%s plus %d days = %s. \n\n",   
          {format_timedate(BIRTH_DATE), days,   
           format_timedate(d3 )  
Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu