I have a channel field named start of campaign and one named end of campaign. I want to make do a conditional that says if today is equal to or later than the start of campaign AND today is before the end of the campaign then do something.

But what I've noticed is if you use %U for formatting it includes the time the entry was created which means the date range is more like 1/1/13 1:13PM -> 1/5/13 1:13PM when what I really want is 1/1/13 12:00AM -> 1/5/13 11:59PM

{if '{start_of_campaign format="%U"}' <= '{current_time format="%U"}' AND '{end_of_campaign format="%U"}' > '{current_time format="%U"}'}

That is what I am currently using but that cant be accurate right?

3 Answers 3


I usually use the following format for dates comparisons

{if '{start_of_campaign format="%Y%m%d"}' <= '{current_time format="%Y%m%d"}' AND '{end_of_campaign format="%Y%m%d"}' > '{current_time format="%Y%m%d"}'}

That should give you numbers that can easily be compared.


I was unable to get Lisa's method to compare properly when it came to different years. I did find this example which seems to be resolving correctly:

{if "{current_time format='%Y-%m-%d - %H:%i:%s'}" > "2010-04-03 - 17:00:00" }

compare dates


Instead of using %U - you can build out the format you want yourself:


  • Thanks! For some reason everything I came across they all mention to use %U for date comparisons. Jan 17, 2013 at 22:38
  • My pleasure, Anthony!
    – Lisa
    Jan 17, 2013 at 23:27
  • Actually looks like this method does not allow for proper date comparison. See for example: {if '12/31/12' < '1/20/13'} hello {/if} will not eval to output hello Jan 21, 2013 at 3:19
  • Yep, I just wanted to get you pointed to those data variables. You should post your final solution as an answer and accept it! :)
    – Lisa
    Jan 21, 2013 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.