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. Undefined behaviour of QDate when converted to string
QtWS25 Last Chance

Undefined behaviour of QDate when converted to string

Scheduled Pinned Locked Moved Solved General and Desktop
qdatec++ qt
2 Posts 2 Posters 418 Views
  • 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.
  • AhtiA Offline
    AhtiA Offline
    Ahti
    wrote on last edited by aha_1980
    #1

    I am trying to convert current system time to day month year format and store that in database table.

    main.qml

    QSqlQuery q;
    QString date = QDate::currentDate().toString("dddMMMyyyy");
    q.exec("insert into users values(1, 'David', 'London', '"+date+"')");
    qDebug() << "Error: " << q.lastError();
    

    error:

    QSqlError("22007", "QPSQL: Unable to create query", " ERROR: invalid input syntax for type date: \"SunFeb2020\"\nLINE 1: ...ers values(1, 'David', 'London', 'SunFeb202....\n ^\n(22007)")

    what is a signature ?? Lol

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      If the database table type is of type date, it wont like a string formatted as
      SunFeb2020 so you need to match the toString format to the one expceted by the DBMS.

      1 Reply Last reply
      5

      • Login

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