How to insert Date to ArangoDB? - json

I can't understand what format use ArangoDB for date storage.
Attempt to insert date in such format:
{"name": "vasia", "date": date("2013-01-15")}
std.json.JSONException#C:\vibe-d-0.7.24\source\vibe\data\json.d(1116): (1): Error: Expected valid JSON token, got 'date("2013-0'.
It's look like vibed JSON module fail on this string, but what format use Arango?
String in format {"name":"vasia","date":"2013-01-15"} inserting in DB successfully, but I can't understand is it's inserting as text or as Date object?

Is it inserting as text or as
Date object?
As text, because ArangoDB only supports JSON data types. JSON doesn't have a Date type, so dates are usually encoded as strings. How you actually do that is up to you, but since you're using D, I suggest you use Date.toISOExtString. For a few other options, see this question.

I haven't used ArangoDB, but the ArangoDB date documentation suggest you use something like DATE_TIMESTAMP("2013-01-15T14:19:09.522") and / or DATE_ISO8601("2013-01-15T14:19:09.522Z"). Hope this helps.

Related

Parse Timestamp object from stringified JSON in BigQuery

I have a stringified JSON column in BigQuery that looks like this:
{"status":0,"buyEquipment":false,"created":{"_seconds":1603578346,"_nanoseconds":909000000},"total":0,"events":{"1603578346909":{"status":0}},"approvalStatus":0,"userId":"xAdkXoah6LMXI4xy9SZ14NUGJIH3","facilityId":"-MF_DJYYyRKbW4fs91v_","orderSize":0,"facility":{"name":"Data Center ehf.","photo":"-MF_cjRQ3dWW3NRMJC6I","province":"Southern Peninsula","city":"Reybaer"},"priceKWh":0.01}
I am attempting to extract certain values from it like so:
SELECT
JSON_EXTRACT(data, '$.created') AS Date_Created
FROM table
And I get something like this:
{"_seconds":1607095273,"_nanoseconds":847000000}
Because it is clearly nested. I am not familiar with how the database being imported from (Firestore) handles timestamp objects, but this is how it is being imported into BigQuery.
I would like to either
Turn this into a more familiar Timestamp format using a single BigQuery or Standard SQL command if possible,
or if not just extract it to a format where it is an easy conversion to human readable date in BigQuery.
I have tried various BigQuery builtin functions to no avail. Thank you!
I would like to ... just extract it to a format where it is an easy conversion to human readable date in BigQuery.
Use below (quite self-explanatory)
select
date(timestamp_seconds(cast(json_extract(data, '$.created._seconds') as int64))) AS Date_Created
from table
if applied to sample data in your question - output is

How to insert stringified json value at just one column in mysql

I am asked to enter a stringified json value in a column named show_cast in the format of Release: and Date: but I don't have any idea how to do that.
The table simply contains of three columns a token , time and genre. The time has to be a stringified json.
I tried to simply put that using { and simple : but that doesn't seem to work. They say that {{release:,time:},{release:,date:},,,,} should be converted in stringify and then inserted into the database. I don't know how to do that and I don't see any resource like this out there. To be honest I didn't even know about this until I was given this task.
insert into show_reality values("project_123","{{release:2017,date:04-11},{release:2019,date:12-03}}","Action");
I have done this but I don't think it is a stringified json.
Thanks in Advance.

Parsing Custom Date Format in MySQL

Problem
I need to query out a date value for use in some ETL processing. However, the data is stored in MySQL as a VARCHAR column in values like 1/1/19.
What I've tried
A simple CAST(myDateColumn as DATE) fails as I get values like 0001-01-19 returned back.
Question
Am I able to pass a custom date format string into the CAST call somehow to tell it how to parse out the date parts? If not, could a SUBSTRING type of function help here?
As discussed in the comments above, you can use the STR_TO_DATE() function to parse a string into a proper YYYY-MM-DD date.

Date format changes strangely

They're pretty stored in the database.
But when i take it from the node and sprinkle it into json, it changes into this format.
YY-mm-dd HH:ii:ss -> YY-mm-ddThh:ii:ss,000Z,
Why does it happen and How can i fix it?
It is getting converted to a date object and when you stringify the javascript object it will call the date.toISOString() format, take a look at this:
Node.js - How to format a date string in UTC
If you post some code we can help you.

convert json to highcharts standard multiple series

I have data from my db that i convert to json as the following
[{"name":"partner1","cost":"311328","date":"2013-04-01"},
{"name":"partner1","cost":"363780","date":"2013-04-02"},
{"name":"partner1","cost":"364062","date":"2013-04-03"},
{"name":"partner1","cost":"283128","date":"2013-04-04"},
{"name":"partner1","cost":"322608","date":"2013-04-05"},
{"name":"partner2","cost":"425538","date":"2013-04-01"},
{"name":"partner2","cost":"263670","date":"2013-04-02"},
{"name":"partner2","cost":"213192","date":"2013-04-03"},
{"name":"partner2","cost":"378726","date":"2013-04-04"},
{"name":"partner2","cost":"532698","date":"2013-04-05"}]
How will be the best wat to convert this json data into highcharta standard for multiple series data?
My last resort is to do multiple query to db to construct the data, but i think it will comnsume server time resource.
Appreciate for the help.
regards,
Ideally you'd transform the data to look like this:
{"partner1": [
[Date.UTC(2013,3,1), 311328],
[Date.UTC(2013,3,2), 363780],
...
Note that the month argument to Javascript's Date function starts from 0 (January).
First of all you should use timestamp as dates (i.e by Date.UTC() ), morever values should be number, not string.