# Number of days between 2 dates

John Dixon dixonja at hotmail.co.uk
Wed Apr 16 12:47:58 EDT 2014

```This seems to work...

on mouseUp
put the short date into dayNow
convert dayNow to seconds
put dayNow into startCalc
convert dayNow to dateItems
put item 1 of dayNow into theYear

put "01/01/" & theYear into theYearStart
convert theYearStart to seconds
put theYearStart into endCalc

put startCalc - endCalc into tempCalc
put trunc(tempCalc/86400)
end mouseUp

> Date: Wed, 16 Apr 2014 18:45:48 +0200
> From: m.schonewille at economy-x-talk.com
> To: use-livecode at lists.runrev.com
> Subject: Re: Number of days between 2 dates
>
> Hi Jbv,
>
> This subject has been discussed very frequently. You may want to search
> the archives for a solution.
>
> Probably, all will work fine if you take 12:00 instead of 00:00. DST may
> be the culprit.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> KvK: 50277553
>
> Installer Maker for LiveCode:
> http://qery.us/468
>
> Buy my new book "Programming LiveCode for the Real Beginner"
> http://qery.us/3fi
>
> LiveCode on Facebook:
>
> On 4/16/2014 18:25, jbv at souslelogo.com wrote:
> > Hi list,
> >
> > I need to calculate the number of days between any date and
> > january 1st of the same year.
> > So I tried this :
> >     put "1/31/14" && "0:00 AM" into tdate
> >     convert tdate to long seconds
> >     put "1/1/14" && "0:00 AM" into date0
> >     convert date0 to long seconds
> >     put (tdate - date0)/86400
> >
> > which seems to work and returns an integer.
> > When I try this as 1st line of my script :
> >     put "3/30/14" && "0:00 AM" into tdate
> > it still works (returns 88).
> >
> > And suddenly, the following :
> >     put "3/31/14" && "0:00 AM" into tdate
> > returns 88.958333
> >
> > Any idea ?
> >
> > Thanks,
> > jbv
> >
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

```