Hey Guys
I am new to roku development.
I have an issue with datetime.
I have two strings.
e.g “24-9-15” and “2-10-15”
Both are two strings.
I want to find out the difference(in days) between them.
Can you please help me out as soon as possible.
Hey Guys
I am new to roku development.
I have an issue with datetime.
I have two strings.
e.g “24-9-15” and “2-10-15”
Both are two strings.
I want to find out the difference(in days) between them.
Can you please help me out as soon as possible.
The simplest way is probably to reformat the strings as ISO 8601 strings, then convert to roDateTimes with roDateTime.FromISO8601String, then convert to seconds with roDateTime.AsSeconds and finally subtract the seconds and divide by 86400.
–Mark
Hi first of all thanks a lot
Can you please provide me sample code
Following info here: http://sdkdocs.roku.com/display/sdkdoc/ifDateTime
I came up with this (untested):
FUNCTION getDateDiff(myISODate1, myISODate2) AS INTEGER ' dates are ISO 8601 strings
date1 = CreateObject("roDateTime")
date2 = CreateObject("roDateTime")
myDate1 = date1.FromISO8601String(myISODate1)
myDate2 = date2.FromISO8601String(myISODate2)
myDate1Sec = myDate1.AsSeconds()
myDate2Sec = myDate2.AsSeconds()
diffSec = myDate2Sec - myDate1Sec
diffDay = diffSec\86400 ' Using \ instead of / will return an integer, ignoring remainder/fraction/decimal
RETURN diffDay
END FUNCTION
But I’ve never used roDateTime, so I might be doing it wrong. And I don’t know how to get your dates into ISO 8601 strings in the first place.
Ok thanks a lot.I will try