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 27 Oct 2018, 22:28 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)

    R 1 Reply Last reply 27 Oct 2018, 22:52
    0
    • C Caio.Sousa
      27 Oct 2018, 22:28

      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)

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 27 Oct 2018, 22:52 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 27 Oct 2018, 22:57 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 28 Oct 2018, 21:55
        4
        • M mad-hatter
          27 Oct 2018, 22:57

          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 28 Oct 2018, 21:55 last edited by
          #4

          @mad-hatter Thanks

          1 Reply Last reply
          0

          1/4

          27 Oct 2018, 22:28

          • Login

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