I am want to compare two core dates. I am trying to increment the first date in a loop until its greater than the second date. I have simplified my code down and still don’t understand why it won’t work. It seems to bump the date up properly but falls out of the loop after one pass. It’s probably something simple but i’m not seeing it. I’d appreciate any help.
Thanks
Using xojo.core
dim di as new xojo.Core.DateInterval
dim iDateIncriment as Date = xojo.core.date.Now
dim iDateEnd as Date = xojo.core.date.Now
Thanks to all who replied! Tried “Seconds” and "SecondsFrom1970.That seemed to do the trick. Both worked. I thought that was just to get more precise and not necessary.
Adding SecondsFrom1970 allowed the date to increment properly but the date compare failed to function properly when it should have exited the loop. This is what finally worked:
Using xojo.core
dim di as new xojo.Core.DateInterval
dim iDateIncriment as Date = xojo.core.date.Now
dim iDateEnd as Date = xojo.core.date.Now
Seriously? That is a huge detrement to SQL processing in my opinion…
Guess once the “current” framework is totally deprecated in favor of this “new” one, it when it will be time to move on… which would be a shame…
and for those of you using iOS, and MUST use the new frame work…
here are simple SWIFT extensions to NSDATE, feel free to translate them to a declare or plugin or whatever
var SQLDate:String {
set {
// let fmt=NSDateFormatter()
fmt.dateFormat=fmt_SQLDate
var tempStr:String=newValue
// Ignore any TIME component
if tempStr.Len()>fmt_SQLDate.Len() {
tempStr=(tempStr as NSString).substringWithRange(NSRange(location:0,length:fmt_SQLDate.Len()))
}
if let temp=fmt.dateFromString(tempStr) {
assign_date(NSDate(timeInterval: 0, sinceDate: temp))
} else {
mERROR=true
}
}
get {
// let fmt=NSDateFormatter()
fmt.dateFormat=fmt_SQLDate
return String(fmt.stringFromDate(theDate))
}
}
var SQLDateTime:String {
set {
var tempStr:String=newValue
// let fmt=NSDateFormatter()
// Append a bogus Time, if one is not supplied
if tempStr.Len()<fmt_SQLDateTime.Len() {
tempStr=tempStr+" 00:00:00"
}
fmt.dateFormat=fmt_SQLDateTime
if let temp=fmt.dateFromString(tempStr) {
assign_date(NSDate(timeInterval: 0, sinceDate: temp))
} else {
mERROR=true
}
}
get {
// let fmt=NSDateFormatter()
fmt.dateFormat=fmt_SQLDateTime
return String(fmt.stringFromDate(theDate))
}
}
oh… just noticed there are references here to other parts of a much larger DATE class I wrote, but you get the idea
It isn’t called that, but to be clear to others reading this thread that functionality certainly exists- the new framework has standardized on FromText/ToText to transform things from/to text. SQLDateTime format is a common textual representation and thus you can just do a FromText or ToText on a Xojo.Core.Date without needing to pass any kind of other format and you’re off to the races.