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. QDate::daysTo but only with yyyy-MM-dd
Forum Updated to NodeBB v4.3 + New Features

QDate::daysTo but only with yyyy-MM-dd

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.4k Views 1 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.
  • F Offline
    F Offline
    Forgive
    wrote on last edited by
    #1

    Well i'm trying to use QDate::daysTo to check the difference between 2 dates. But daysTo param accepts a QDate, but QDate returns: QDate("sun feb 19 2012")

    In easy words.

    I want QDate to only return yyyy-MM-dd and not QDate("sun feb 19 2012") (Today...) something like.. .QDate("2012-02-19") so i can easily do:

    @ QDate m_curdate = QDate::currentDate();

        QDate::fromString("2012-02-20").daysTo(m_curDate);
    

    @

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      you can use this tempDateTime.toString("yyyy/MM/dd") Note MM should be in capital

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Forgive
        wrote on last edited by
        #3

        I don't know if i'm understanding you but .daysTo() parameter only allows QDate.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KA51O
          wrote on last edited by
          #4

          like this
          @QDate::fromString("2012-02-20").daysTo(m_curDate).toString("yyyy/MM/dd");@

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            Perhaps you can use QTimeSpan?

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Forgive
              wrote on last edited by
              #6

              [quote author="KA51O" date="1329723613"]like this
              @QDate::fromString("2012-02-20").daysTo(m_curDate).toString("yyyy/MM/dd");@[/quote]

              daysTo() returns an integer.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                KA51O
                wrote on last edited by
                #7

                Sorry my bad. Didn't really spend too much time on thinking about the problem. I still don't fully understand what your problem is and what you're trying to achieve.

                @
                QDate::fromString("2012-02-20").addDays(QDate::fromString("2012-02-20").daysTo(m_curDate)).toString(“yyyy/MM/dd”);
                @

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Forgive
                  wrote on last edited by
                  #8

                  Sorry, what i'm trying to do is to check how many days until a date. I mean, i have 2012-02-20 (20 February 2012). I want to count how many days until today (Since today is 25, 5 days).

                  EDIT: Okay, i've got it. Was something like creating a TempDate and doing QDate::fromString("2012-02-20", "yyyy-MM-dd") then doing temp.daysTo(QDate::currentDate)

                  @ QDate temp;
                  temp = QDate::fromString("2012-02-20", "yyyy-MM-dd");
                  qDebug() << temp.daysTo(QDate::currentDate());@

                  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