Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Difference between two dates.
Forum Updated to NodeBB v4.3 + New Features

Difference between two dates.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Caio.Sousa
    wrote on last edited by
    #1

    Hello guys

    I'm doing a job and I have a question.

    I got 2 dates from a QDate, and I need to subtract the 2 dates and pick up the days.

    It is a hotel program, the user must enter the day of entry and the day of departure and need to know how many days he stayed to multiply by the price.

    How can I make a difference between these two dates?

    QDate IniDate =ui->dateIni->date();
        QDate endDate =ui->dateEnd->date();
    
    QString dateIni = IniDate.toString();
        QString dateEnd = endDate.toString();
    

    I need (dateEnd - dateIni)

    raven-worxR 1 Reply Last reply
    0
    • C Caio.Sousa

      Hello guys

      I'm doing a job and I have a question.

      I got 2 dates from a QDate, and I need to subtract the 2 dates and pick up the days.

      It is a hotel program, the user must enter the day of entry and the day of departure and need to know how many days he stayed to multiply by the price.

      How can I make a difference between these two dates?

      QDate IniDate =ui->dateIni->date();
          QDate endDate =ui->dateEnd->date();
      
      QString dateIni = IniDate.toString();
          QString dateEnd = endDate.toString();
      

      I need (dateEnd - dateIni)

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Caio.Sousa said in Difference between two dates.:

      How can I make a difference between these two dates?

      QDateTime::secsTo() / QDateTime::daysTo()

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      4
      • M Offline
        M Offline
        mad-hatter
        wrote on last edited by
        #3

        Have a look herre :-
        https://forum.qt.io/topic/27906/difference-in-days-months-and-years-between-two-dates

        Regards

        C 1 Reply Last reply
        4
        • M mad-hatter

          Have a look herre :-
          https://forum.qt.io/topic/27906/difference-in-days-months-and-years-between-two-dates

          Regards

          C Offline
          C Offline
          Caio.Sousa
          wrote on last edited by
          #4

          @mad-hatter Thanks

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved