Results 1 to 4 of 4

Thread: Greater or equal than and smaller or equal than not working..

  1. #1
    Join Date
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Greater or equal than and smaller or equal than not working..

    Hi all!

    I have this small function that checks a day is between 2 dates.
    I give for example as starting date 20/04/2011 and as end date 25/04/2011.
    Then I check if the date 22/04/2011 is in between but the operator >= and the <= are not working very well.

    Syear = 2011, Eyear = 2011, year = 2011;
    Smonth = 04, Emonth = 04, month = 04;
    Sday = 20, Eday = 25, day = 22;



    Qt Code:
    1. if((Syear() >= year) and (Eyear() <= year)){
    2. cout << "Year match" << endl;
    3.  
    4. if((Smonth() >= month) and (Emonth() <= month)){
    5. cout << "Month match" << endl;
    6.  
    7. if((_Temp->getSday() >= day) and (_Temp->getEday() <= day)){
    8. cout << "Day match" << endl;
    9. }
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    output of the program:

    Year Match
    Month Match

    but day doesn't

    then I added this:

    Qt Code:
    1. if(Sday() >= day) cout << "day >=" << endl;
    2. if(Eday() <= day) cout << "day <=" << endl;
    To copy to clipboard, switch view to plain text mode 

    with:
    Sday = 20, Eday = 25, day =22;
    No output

    with:
    Sday = 20, Eday = 25, day =20;
    output is:
    day >=


    and with:
    Sday = 20, Eday = 25, day =25;
    output is:
    day <=

    that means it only check for days = to Sday or Eday.

    What is wrong?

    thanks
    Last edited by ruben.rodrigues; 26th April 2011 at 10:17.

  2. #2
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Greater or equal than and smaller or equal than not working..

    You say that Sday = 20, Eday = 25, day = 22;. Correct? Then if that is case the case first kondition is not true here. Sday is not bigger nor equal to day, so day is not a match
    Qt Code:
    1. if((_Temp->getSday() >= day) and (_Temp->getEday() <= day))
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Greater or equal than and smaller or equal than not working..

    Quote Originally Posted by meazza View Post
    You say that Sday = 20, Eday = 25, day = 22;. Correct? Then if that is case the case first kondition is not true here. Sday is not bigger nor equal to day, so day is not a match
    Qt Code:
    1. if((_Temp->getSday() >= day) and (_Temp->getEday() <= day))
    To copy to clipboard, switch view to plain text mode 
    correct. I have noticed that a couple of minutes ago. I have to put the day before the Sday and the Eday.

    This is what happens when you have 4 days of holydays and the playstation network is down

    Thanks

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Greater or equal than and smaller or equal than not working..


    Qt Code:
    1. if(Sday() >= day) cout << "day >=" << endl;
    2. if(Eday() <= day) cout << "day <=" << endl;
    To copy to clipboard, switch view to plain text mode 
    with:
    Sday = 20, Eday = 25, day =22;
    No output
    In your code, you are treating Sday and Eday as functions (possibly constructors) but in your data example you treat them as integers. If that's really a piece of your code and not just a typing mistake, there's some information missing here.

Similar Threads

  1. What does Updatedata function in MFC equal with Qt?
    By nthung in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2010, 11:58
  2. Replies: 6
    Last Post: 5th March 2010, 11:54
  3. Forcing equal row heights in QTableWidget
    By wssddc in forum Newbie
    Replies: 2
    Last Post: 2nd November 2009, 01:16
  4. How to set QWizard size equal for all its pages
    By kalos80 in forum Qt Programming
    Replies: 0
    Last Post: 9th June 2009, 09:00
  5. Equal scales
    By sukram in forum Qwt
    Replies: 1
    Last Post: 22nd July 2008, 07:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.