Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 2 of 2 total |
Date Oops |
Fri, Mar 13 2015 10:44 AM | Permanent Link |
Matthew Jones | I've got a problem with dates:
var tmToday := Date; tmDateTime : DateTime; begin tmDateTime := // Some routine that gets a date if DayOf(tmDateTime) > DayOf(JulToDate(DateToJul(tmToday) - 5)) then // sort of works, but oops! Now, this code is supposed to see if the date is within the last 5 days, and if so, show a friendly "Thursday" instead of "2015-03-03" or something. Which it does, but only for recent dates. Dates last month are now being shown as Saturday too, which is wrong! Turns out the DayOf() function is the day of the month. What is the best way to make this "over 5 days ago"? The DateTime type is just milliseconds, so is it really a matter of subtracting 5 * 86,400,000 from the value? I guess so, but would quite like a nicer way. -- Matthew Jones |
Fri, Mar 13 2015 10:55 AM | Permanent Link |
Matthew Jones | Matthew Jones wrote:
> What is the best way to make this "over 5 days ago"? The DateTime type > is just milliseconds, so is it really a matter of subtracting 5 * > 86,400,000 from the value? I guess so, but would quite like a nicer > way. This seems to work well enough: function DaysSince(tmEventDate : DateTime) : Integer; var nMilliSecsPerDay : Integer; tmToday : DateTime; begin tmToday := Date; nMilliSecsPerDay := 86400000; Result := ((tmToday - tmEventDate) div nMilliSecsPerDay) + 1; end; -- Matthew Jones |
This web page was last updated on Friday, September 13, 2024 at 03:42 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |