https://questdb.io logo
Title
k

Klaus Schröder

02/28/2023, 4:38 PM
Hi Beginners question: I have existing data that only has date column(s), not datetime. I would like to use QuestDB’s SAMPLE BY function to build timeline charts from my data. I do not need fine granularity, day, week or month is enough. How can I import and/or insert my data so that my date column is treated as a designated timestamp?
a

Alex Pelagenko

02/28/2023, 4:47 PM
Date can be written to timestamp, no problem
How are you importing the data?
k

Klaus Schröder

02/28/2023, 5:23 PM
Hi Alex seems that I messed something up in my first tests. It seems to work fine now. My data.csv:
estimatedate;estimateid;equipmentnumber
2019-04-11;f713be4d-f6a5-443c-a8fe-6988a327d777;ZIMU1001248
2019-05-09;2a503f25-646d-4588-8b9a-1386d6a891c8;TRLU6810623
2019-10-01;06cf83ad-f43b-4c4a-83fe-a12a02216d20;CXDU2241203
2019-12-03;3f989ff9-f8dd-479b-8408-66251834c317;UETU5766937
2020-01-02;f601e176-714d-4ea1-b185-a354c9029855;AEXU4518019
2020-01-02;5063a5d1-a5b1-481c-94a1-613b3da76d79;AEXU4525553
2020-01-02;7355cccd-dd5a-4688-9519-e62b5c5a98b9;BMOU9659583
2020-01-02;4ef87abe-2ba7-4282-b503-ccb8378c1fff;TCLU1342813
2020-01-02;c42c96b9-c359-4c97-8a13-77744e43ce36;AEXU4507251
2020-01-07;dc530a1a-77ca-4d76-9337-8219e8a85b16;AEXU4525337
My schema-ts.json:
[
  {
    "name": "estimatedate",
    "type": "TIMESTAMP",
    "pattern": "yyyy-MM-dd"
  },
  {
    "name": "estimateid",
    "type": "STRING"
  },
  {
    "name": "equipmentnumber",
    "type": "STRING"
  }
]
$ curl -F schema=@schema-ts.json -F data=@estimates-ts.csv  '<http://localhost:9000/imp?overwrite=true&name=estimates-ts2&timestamp=estimatedate>'
+-----------------------------------------------------------------------------------------------------------------+
|      Location:  |                                     estimates-ts2  |        Pattern  | Locale  |      Errors  |
|   Partition by  |                                              NONE  |                 |         |              |
|      Timestamp  |                                      estimatedate  |                 |         |              |
+-----------------------------------------------------------------------------------------------------------------+
|   Rows handled  |                                                50  |                 |         |              |
|  Rows imported  |                                                50  |                 |         |              |
+-----------------------------------------------------------------------------------------------------------------+
|              0  |                                      estimatedate  |                TIMESTAMP  |           0  |
|              1  |                                        estimateid  |                   STRING  |           0  |
|              2  |                                   equipmentnumber  |                   STRING  |           0  |
+-----------------------------------------------------------------------------------------------------------------+
Thanks for your quick feedback