Re: date math
This WebDNA talk-list message is from 2005
It keeps the original formatting.
numero = 61838
interpreted = N
texte = Dave, the problem with this is that if a time was appended that isless than the current time, you have a negative integer.This is why, when dealling with Date and Time down to the seconds,you will always do better with "seconds since epoch".DonovanDave Hurley wrote:> Since you have your date and time fields separated, you may need to > create dates and times with them. By enclosing the whole thing in {} and > setting it as a math variable, it will be in the form of an integer, > which simplifies any calculations:> > [text]Emon=04[/text]> [text]Eday=20[/text]> [text]Eyr=2005[/text]> > [text]EHr=11[/text]> [text]Emin=45[/text]> [text]Esec=45[/text]> > entered date as integer = [Math]Edate={[Emon]/[Eday]/[Eyr]}[/Math]> > entered time as integer = [Math]Etime={[EHr]:[EMin]:[Esec]}[/Math]> > Now do the same for the current date and time:> > today's date as integer = [Math]Tdate={[date]}[/Math]> > today's time as integer = [Math]Ttime={[time]}[/Math]> > Now subtract one from the other:> elapsed days as integer = [Math]elapsedD=[Tdate] - [Edate][/Math]
> > elapsed time as integer = [Math]elapsedT=[Ttime] - [Etime][/Math]> > To convert back to days, hours, minutes and seconds, use the format tag:>
> [elapsedD] days, [Format Seconds_To_Time %H hours, %M minutes and %S > seconds ago.][elapsedT][/Format]> > > Dave Hurley> Biology Department> University of Washington-- =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o DONOVAN D. BROOKE Eucalyptus Design <-Web Development (specializing in eCommerce), -> <- Graphic Design, Custom Tags and Labels -> ADDRESS:> Donovan Brooke DBA Eucalyptus Design N2862 Summerville Park Rd. Lodi, WI 53555 PH:> 1.608.592.3567 Web:> http://www.euca.us =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list
.To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Associated Messages, from the most recent to the oldest:
Dave, the problem with this is that if a time was appended that isless than the current time, you have a negative integer.This is why, when dealling with Date and Time down to the seconds,you will always do better with "seconds since epoch".DonovanDave Hurley wrote:> Since you have your date and time fields separated, you may need to > create dates and times with them. By enclosing the whole thing in {} and > setting it as a math variable, it will be in the form of an integer, > which simplifies any calculations:> > [text]Emon=04[/text]> [text]Eday=20[/text]> [text]Eyr=2005[/text]> > [text]EHr=11[/text]> [text]Emin=45[/text]> [text]Esec=45[/text]> > entered date as integer = [math]Edate={[Emon]/[Eday]/[Eyr]}[/Math]> > entered time as integer = [math]Etime={[EHr]:[EMin]:[Esec]}[/Math]> > Now do the same for the current date and time:> > today's date as integer = [math]Tdate={[date]}[/Math]> > today's time as integer = [math]Ttime={[time]}[/Math]> > Now subtract one from the other:> elapsed days as integer = [math]elapsedD=[Tdate] - [Edate][/Math]
> > elapsed time as integer = [math]elapsedT=[Ttime] - [Etime][/Math]> > To convert back to days, hours, minutes and seconds, use the format tag:>
> [elapsedD] days, [Format Seconds_To_Time %H hours, %M minutes and %S > seconds ago.][elapsedT][/Format]> > > Dave Hurley> Biology Department> University of Washington-- =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o DONOVAN D. BROOKE Eucalyptus Design <-Web Development (specializing in eCommerce), -> <- Graphic Design, Custom Tags and Labels -> ADDRESS:> Donovan Brooke DBA Eucalyptus Design N2862 Summerville Park Rd. Lodi, WI 53555 PH:> 1.608.592.3567 Web:> http://www.euca.us =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Donovan Brooke
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
WebCat for Unix?? (1997)
WebCat2b15MacPlugin - showing [math] (1997)
random in arizona (2003)
Replace Statement (1997)
Error: Can't open order file. Ignoring [OrderFile] context (2000)
[REPLACE] inside [FOUNDITEMS] (1998)
Internet Advancement (2003)
Lots of bounce errors (2007)
WebCat2 - [format thousands] (1997)
Escape the Root! (2002)
'Carting' into Frames (2000)
b12 cannot limit records returned and more. (1997)
dbQuickView 2.0 (2005)
Transfer of data from Invoice to thank you templates (1998)
Removing [showif] makes a big difference in speed (1997)
problem (how to mark orders as 'opened') (1998)
Looking for 5 to 12 shops with 3 URLs & statements (1997)
select multiple (1997)
Webcat/Webmerchant part II (1998)
New site announcement + Showing once on a founditems (1997)