I have question regarding DateTime, can this be left empty for example
{ value: '',
type: 'DateTime',
metadata: {}
}
I am getting error when sending entity with this attribute that date is invalid format. This is clear as day why but what format i would have to use for empty value.
I failed to find this information on documentation but i could miss it.
Thanks.
You cannot use an empty value for DateTime attributes in NGSIv2 API. You have to provide a properly formatted date in ISO8601 format.
If you need to introduce the "no date" semantics in your system the best approach is to remove the attribute (e.g. DELETE /v2/entities/E/attrs/A if I'm remembering correctly).
Related
I'm trying to convert the date field from YYYY-MM-DD HH:MM:SS:MS to MM/DD/YYYY format in a view using Snowflake database with below condition:
TO_VARCHAR(DATE(SRC_DATE),'MM/DD/YYYY')
I'm able to convert the date to expected format with above condition, but when I try to load data from this view to different table using a sp its failing with below error:
Failed: Code: 939 - State: 22023 - Message: SQL compilation error: error line 1 at position 1,058
too many arguments for function [TO_VARCHAR(VALID_FROM_DATE, 'YYYYMMDDHH24MISS.FF9')] expected 1, got 2 - Stack Trace: Statement.execute, line 9 position 58
Need help in getting the right logic to fix this error. How can I do this?
You just need to do:
TO_VARCHAR(SRC_DATE,'MM/DD/YYYY')
I’m wondering why you are trying to change the format of a date in Informatica? A date is held as a number, the format is just how it is displayed - the underlying number doesn’t change
I'm not sure exactly what's going on yet, but I can walk through some things we do know.
First, the error message says the TO_VARCHAR() function only expected one argument. Knowing this we can look at the documentation for the method. Here we see there are several overloads:
TO_VARCHAR( <expr> )
TO_VARCHAR( <numeric_expr> [, '<format>' ] )
TO_VARCHAR( <date_or_time_expr> [, '<format>' ] )
TO_VARCHAR( <binary_expr> [, '<format>' ] )
Only one of these overloads (the first) fits the error message. Most of the overloads allow multiple arguments, but only if the first argument matches certain types: numeric, date/time, or binary. This does include the expected date result of the DATE() function
Therefore we can conclude somehow the result of the DATE(SRC_DATE) call is NOT a valid <date_or_time_expr> in every case, such that we at least sometimes end up with the first overload.
While the documentation for Date() does allow several ways for the function to return NULL, it also explicitly returns a Date type:
The data type of the returned value is DATE.
Thus I'd still expect it to always match the third overload above. The only other possible result from Date() is the conversion fails, in which case we'd see a different error message entirely.
The best explanation I could guess at is the return type for Date() doesn't matter if the result is NULL (that is: NULL is inherently untyped for this purpose), such that you're still ending up with the first overload, which does not allow the 2nd argument.
You could possibly fix this by adding a COALESCE() so NULL is converted to a valid consistent throw-away date expression; something like, say, 1900-01-01. If it's important to preserve NULL values you can then in turn also wrap the whole thing in a NULLIF() call.
Finally, all of this only make sense is SRC_DATE is not already a valid <date_or_time_expr>. That is, if it's something like a varchar column. This in itself would already be a mistake in schema design. On the other hand, if it is already a datetime column, there is no need at all to call Date(), and it can be used directly with TO_VARCHAR()... but with likely the same caveat about NULL values you're already seeing.
We can test this theory by trying the following:
TO_VARCHAR(DATE(IFNULL(SRC_DATE,'1900-01-01')),'MM/DD/YYYY')
I am using Sequelize to map objects to my already existing database, in this database they didnt use the auto-generated timestamps, they did their own datetime work, the current way the database stores the date is in YYYY-MM-DD HH:MM:SS.MS however using sequelize, i am returning a date that looks like YYYY-MM-DD HH:MM:SS.MS +00:00 and i believe this is whats tripping me up. as i am receiving an error Conversion failed when converting date and/or time from character string. I tried even accessing the Date() object and building my own date string, and i got the same error. even though it follows the correct formatting.
for my model i have this at the CreateDateTime (This is the name of the field in the database.
CreateDateTime: {
type: DataTypes.DATE,
defaultValue: `${date.getFullYear()}-${date.getMonth()}-${date.getDay()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`,
},
UpdateDateTime: {
type: DataTypes.DATE,
},
I have also, renamed the timestamps that sequelize provides to the appropriate names above. I am not sure much more of how to get around this issue besides maybe using the timestamps provided by sequelize and dropping the ones in the existing.. though id rather not do this. even though eventually ill move this database to a better schema in which the timestamps are autogenerated.
is there a different way around this error? No matter what i seem to do the sql insert query always seems to tack on the +00:00 to the end, is this some kind of default value of using the DataType DATE? is there a different data type i should be using?
So I figured out that the previous team likely wasn't storing an actual datetime timestamp, because once i changed the DataType from DATE to STRING it worked just fine, i was no longer receiving this error, but it still strikes me as strange, because using my DB exporer (i use Razor) when i was having the table described to me, it clearly stated that these fields where of datetime and not varchar, so im not sure why this works, only that it follows the appropriate pattern and it does indeed work.
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 trying to create a Json schema regex to have a timestamp validation in milliseconds. Eg.20140508172846.127.
I tried like this Pattern:^[0-9] it's not working. please suggest any other way to perform timestamp validation.
You should use a regex. The problem is the pattern you provided does not match floating point numbers.
You could try with:
(\d+(?:\.\d*)?|\.\d+)\s+(\S+)
But you would need to specify exactly which timestamps values are allowed (and you will find for sure an answer in stackoverflow)
I am sending a JSON PUT request to Grails. In the JSON object, I have a date string. I have searched and experimented, but I cannot determine the default date string format that GORM wants to parse the date string. In all my attempts I get the following error:
java.lang.IllegalArgumentException: Could not parse date: Unparseable date
I just want to know the default format GORM expects and I will happily format the date string in that format before sending it to the server.
I suppose you face this issue during data binding.
Reason:
Default date format for binding is yyyy-MM-dd HH:mm:ss.S
Solution:
The default data format can be changed using PropertyEditorRegistrar. Follow this for details.