Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. SQL ts als Datum/Uhrzeit anzeigen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    SQL ts als Datum/Uhrzeit anzeigen

    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wendel6000 last edited by

      Hallo,
      ich bin SQL-Frischling.
      Auf meine DB greife ich mit Sequel-Ace zu.
      Kann ich die Zeitwerte in "ts" als Datum mit Uhrzeit darstellen/umstellen?

      Bildschirmfoto 2022-06-10 um 10.49.37.png

      BananaJoe D OliverIO 3 Replies Last reply Reply Quote 0
      • BananaJoe
        BananaJoe Most Active @wendel6000 last edited by

        @wendel6000 willst du wissen wie das Allgemein geht? Der TS ist ein UNIX-Timestamp ( https://www.unixtimestamp.com/ ), das sind also die Sekunden seit dem 1.1.1970.
        In ioBroker sind das in JavaScript auch gerne die Zeit in Millisekunden statt Sekunden, wenn es nicht passt musst du die letzten 3 Stellen kürzen ( durch tausend teilen), z.B. in Blockly beim Datums-Objekt.

        Vorteil dieser Darstellung/Nutzung ist das man prima damit Rechnen kann (oder sortieren usw.)

        Sequel-Ace sagt mir nichts falls es um die Darstellung darin geht.

        1 Reply Last reply Reply Quote 0
        • D
          darkiop Most Active @wendel6000 last edited by

          @wendel6000

          select x1.id as id
          ,x2.name as object
          ,from_unixtime(floor(ts/1000)) as 'timestamp'
          ,ts as 'unixtime'
          ,val as value
          from iobroker.ts_number x1
          join datapoints x2 on x1.id = x2.id
          where x1.id IN (4711)
          -- and year(from_unixtime(floor(ts/1000))) = 2021
          order by from_unixtime(FLOOR(ts/1000)) DESC
          LIMIT 20;
          
          
          1 Reply Last reply Reply Quote 0
          • OliverIO
            OliverIO @wendel6000 last edited by OliverIO

            @wendel6000

            oder du lässt dir den timestamp direkt formatiert über ein sql anzeigen
            hier die datumsfunkiotnen am beispiel sqlite
            https://www.sqlite.org/lang_datefunc.html
            mit strftime kann man sich das beliebig formatieren lassen
            wenn du da hilfe brauchst und nicht weiterkommst, dann meld dich

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Support us

            ioBroker
            Community Adapters
            Donate
            FAQ Cloud / IOT
            HowTo: Node.js-Update
            HowTo: Backup/Restore
            Downloads
            BLOG

            858
            Online

            31.8k
            Users

            80.0k
            Topics

            1.3m
            Posts

            4
            4
            1166
            Loading More Posts
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes
            Reply
            • Reply as topic
            Log in to reply
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
            The ioBroker Community 2014-2023
            logo