Results 1 to 3 of 3

Thread: QDate minus one week

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QDate minus one week

    Hi,

    How can I obtain the Date minus one week? p.e.: the date is(yyyy-mm-dd) "2008-05-03" and I want to get "2008-04-26".

    QDate class let's me add days, months and years, but don't let me do substraction.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,539
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDate minus one week

    From QDate::addDays doc :
    Returns a QDate object containing a date ndays later than the date of this object (or earlier if ndays is negative).

    So just do QDate::addDays(-7)

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDate minus one week

    Hi,

    Yes yes, just writing code before reading doc.

    Thanks,
    Òscar Llarch i Galán

Similar Threads

  1. Problems with QDate
    By cyberboy in forum Qt Programming
    Replies: 4
    Last Post: 25th May 2008, 21:17

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
  •  
Qt is a trademark of The Qt Company.