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 is less 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". Donovan Dave 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:

    
  1. Re: Date Math broken on Mac OS X 10.4? ( Tom Duke 2007)
  2. Re: Date Math broken on Mac OS X 10.4? ( Paul Willis 2007)
  3. Re: Date Math broken on Mac OS X 10.4? ( Tom Duke 2007)
  4. Date Math broken on Mac OS X 10.4? ( Paul Willis 2007)
  5. Re: Date Math ( Patrick McCormick 2005)
  6. Re: date math ( Donovan Brooke 2005)
  7. Re: date math ( Dave Hurley 2005)
  8. Re: Date Math ( Donovan Brooke 2005)
  9. Re: Date Math ( "Allen" 2005)
  10. Date Math ( Eddie Z 2005)
  11. Re: date math [2.x] (Aaron Lynch 1999)
  12. Re: date math [2.x] (PCS Technical Support 1999)
  13. Re: date math [2.x] (Marty Schmid 1999)
  14. Re: Date Math (Kenneth Grome 1999)
  15. Re: Date Math (Will Starck 1999)
  16. Re: Date math format (PCS Technical Support 1998)
  17. Re: Date Math bug (Dale LaFountain 1998)
  18. Re: Date Math bug (John Hill 1998)
  19. Re: Date math (Michael Winston 1997)
  20. Re: Webcat 2.0.1 date math bug -> Crash! (wahl@dnai.com (Bernt Wahl) 1997)
  21. Re: Webcat 2.0.1 date math bug -> Crash! (Kenneth Grome 1997)
  22. Webcat 2.0.1 date math bug -> Crash! (Dale LaFountain 1997)
  23. Problems with date math (Michael Winston 1997)
  24. Re: Problems with date math (Olin 1997)
  25. Re: Problems with date math (Grant Hulbert 1997)
Dave, the problem with this is that if a time was appended that is less 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". Donovan Dave 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:

WebDelivery Self-Destruct Timer (2000) Thanks for tips, more quest (1997) Mozilla/4. and Browser Info.txt (1997) New Command prefs ... (1997) Updating Prices in Online Database (1999) can webcat create directories on NT? (1997) authenticating a second user (1997) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Sku numbers (1997) Multiple Admins through users.db (1997) best way to test for the existence of a parameter in a url (2003) emailer (1997) [ot] ascii values for lf and cr (2001) Version f1 status (1997) WebCat2 beta 11 - new prefs ... (1997) AutoNumber not working (2004) [showif [numfound]=0]? (2000) Using Plug-In while running 1.6.1 (1997) Serving images from databases (1998) Sort Order on a page search (1997)