Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    date comparison not working.

    Hi,
    Edit:
    too tired. I forgot to convert from iso date formats.


    I am looping through some dates and making a comparison, in order to generate a variable value. the comparison isn't working properly and I can't seem to work it out.

    Code:
    for info:
    tariff_start='2009-10-01';
    tariff_end = '2010-03-31';
    currdate= '2009-04-01';
    
    
    my $tariff_status = 'no_tariff'; 
    
     if ($currdate >= $tariff_start  &&  $currdate <= $tariff_end){
          $tariff_status = 'has_tariff';
    print qq( ts=$tariff_start : te=$tariff_end : cd=$currdate : ts=$tariff_status <br /> );
    That lot outputs

    ts=2009-10-01 : te=2010-03-31 : cd=2009-04-01 ts=has_tariff

    It should be telling me there is no_tariff
    Can you see what I am overlooking?

    bazz
    Last edited by bazz; 11-21-2009 at 06:40 AM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •