Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Date time comparison (Read 1675 times)
Simon Smailus
Full Member
*
Offline



Posts: 141
Tipton, UK
Date time comparison
Jan 13th, 2015, 11:49am
 
I am using TB for planning a years with of preaching, teaching and other events. Some are today, some yesterday and others in the future.

I have two agents running:

My first agent "Highlights Today":
Query: descendedFrom("Daybook")&$Date=="today"
Action: if($Date=="today"){$Color="orange"}else{$Color=;}

My second agents changes the colour back once the the note's date is no longer in "today"
Query: descendedFrom("Daybook")&($Date!="today")&($Color=="orange")
Action: $Color=;

I'd like to know if I can get more granular? I might have multiple items on one day. Is there a way to get an agent to check for "now" this exact moment and use that for the query? So instead of "today" it would use "now" so events  that have already passed today revert to their normal colour?
Back to top
 
 

Simon Smailus
WWW   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Date time comparison
Reply #1 - Jan 13th, 2015, 12:40pm
 
Date comparisons are tricky!  

Two dates A and B are equal (==) if they occur on the same day.  

However, all dates include a time, and A<B if A is before B.  Thus, it is possible for two dates to be == and < .

     Agent: things that were due earlier today
     Query: $DueDate==date("today") & $DueDate<date("today")

Don't forget that you can use operators to extract components of dates -- e.g. $DueDate.year or $StartDate.hour
Back to top
 
« Last Edit: Jan 14th, 2015, 3:11pm by Mark Bernstein »  
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Date time comparison
Reply #2 - Jan 13th, 2015, 1:40pm
 
If you want to specify things like ‘now’ there are a number of built-in date ‘designators' that you can use. Note that ‘today’ and ‘now’ imply the same things - your Mac’s current system date/time.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Simon Smailus
Full Member
*
Offline



Posts: 141
Tipton, UK
Re: Date time comparison
Reply #3 - Jan 14th, 2015, 2:53pm
 
Many thanks guys, a great help.

Can I ask what's with the &&? Can't find out why you use them. I'm using &. Is there a difference?
Back to top
 
 

Simon Smailus
WWW   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Date time comparison
Reply #4 - Jan 14th, 2015, 3:11pm
 
&& is a typo. I'll correct the original.

(Ever started writing in one language and slipped into another?  It's like that -- a bit of C/C++ slipped into the Tinderbox.)
Back to top
 
« Last Edit: Jan 14th, 2015, 3:11pm by Mark Bernstein »  
WWW   IP Logged
Pages: 1
Send Topic Print