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.
Related
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.
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.
I am new to Cassandra cql (cqlsh 4.1.1, Cassandra 2.0.8.39, CQL spec 3.1.1, Thrift protocol 19.39.0) - using the cql COPY command to a table from a CSV formatted file and I get the following error: Bad Request: unable to coerce '2012/11/11' to a formatted date (long). How do I change a column using cql so that it accepts the date from my CSV file?
as Brian said, there are CQL timestamp type to follow to get CQL query running. Sometimes it looks like quite weird indeed ! I've got the same issue few weeks ago with a date time insert like this one :
INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04');
I got this error : Bad Request: unable to coerce '2012-03-25 02:26:04' to a formatted date (long) ! mmmm... so bad as the date time seems to be correct !
After many tries and before going nuts, I've just added a Z at the end of the time, Z stands for Zulu time which is also UTC and GMT :
INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04Z');
Yessss ! It works ! So do not forget the timezone in your date time values, it could be helpful ! ;-)
There is not a direct way to do that from within CQLSH.
There are a certain set of string date formats which can be coerced. See the CQL Timestamp type documentation page for some examples like:
yyyy-mm-dd HH:mm
yyyy-mm-dd HH:mm:ss
yyyy-mm-dd HH:mmZ
yyyy-mm-dd HH:mm:ssZ
yyyy-mm-dd'T'HH:mm
yyyy-mm-dd'T'HH:mmZ
yyyy-mm-dd'T'HH:mm:ss
yyyy-mm-dd'T'HH:mm:ssZ
yyyy-mm-dd
yyyy-mm-ddZ
As a workaround you could modify your CSV file to adjust the date format, then import it. (In your case it may be as simple as "yyyy/mm/dd" -> "yyyy-mm-dd".)
I just started using webMETHODS today and need to transform a date input value that comes in like this.
Example:
yyyy-mm-dd hh:mm:ss:hh
I need just the date portion of this variable and am currently using pub.date:formatDate which will crash my flow service.
What should I be using?
An alternative would be to use pub.date:dateTimeFormat, which allows you to set an input pattern, for example dd.MM.yyyy hh:mm:ss.
pub.date:formatDate is used to convert a date input to a string output based on a string pattern.
Here you are trying to convert a string input to a string output.
You have to do the following:
a.
First convert the string (Process_date_orig_str) to date format (Process_date_dt)
b. Then use the date (Process_date_dt) to the required string format using pub.date:formatDate to get (Process_date_new_str)
Note: You will have to create your custom java service to convert string to Date.
I played around with this for practise. The 'correct' answer is what Christian Strempfer posted - this is what pub.date:dateTimeFormat is meant to do: transform beween datetime string formats. I'm not sure about your date pattern though - try currentPattern=yyyy-MM-dd HH:mm:ss.SS and newPattern=yyyy-MM-dd
A 'good hacky approach is using pub.string:subString (positions 0 and 10) to simply hack the end off the input string. You can also try regexs -- pub.string:replace, useRegex=true, searchString=^(.{10}).*, replaceString=$1. (searchString=^(.{10}) should also work, but it doesn't)
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.