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
Forum Updated to NodeBB v4.3 + New Features

Undefined behaviour of QDate when converted to string

Scheduled Pinned Locked Moved Solved General and Desktop
qdatec++ qt
2 Posts 2 Posters 424 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.
  • A Offline
    A Offline
    Ahti
    wrote on 16 Feb 2020, 11:42 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 16 Feb 2020, 12:02 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

      1/2

      16 Feb 2020, 11:42

      • Login

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