Hi,
I found a problem receiving a json array in a field of type date with no time,
but also with time no 00:00:00.000Z.
So I wanted to share this problem in order to understand what I should aspect
from 4D.
I know that this is a big question, but what do you think 4D should
interpretate the first two json objects in my below string example in a field
of type Date?
Below a json string example:
[{“Date”: “2018-10-12”}, {“Date”: “2018-10-12T14:00:00.000Z”}, {“Date”:
“2018-10-12T00:00:00.000Z”}]
Here a simpe 4D code to test:
$t_json:="[{"+Char(Double quote)+"Date"+Char(Double quote)+":"+Char(Double
quote)\
+"2018-10-12"+Char(Double quote)+"},"+\
"{"+Char(Double quote)+"Date"+Char(Double quote)+":"+Char(Double quote)\
+"2018-10-12T14:00:00.000Z"+Char(Double quote)+"},"+\
"{"+Char(Double quote)+"Date"+Char(Double quote)+":"+Char(Double quote)\
+"2018-10-12T00:00:00.000Z"+Char(Double quote)+\
"}]"
JSON TO SELECTION([Reservations];$t_json)
All field records are filled with date 10-12-2018 (MM-DD-YYYY) so the field
Date looks like I aspected, but if I want to search for that date:
Query([Reservation];[Reservetions]Date=!2018-10-12!)
I’m going to find only one record. The last json object with Date =
“2018-10-12T00:00:00.000Z”.
If I write a query like this:
Query([Reservation];[Reservetions]Date>=!2018-10-12!*)
Query([Reservation];&;[Reservetions]Date<=!2018-10-12!)
I will find all records in the json string.
I have to suppose that a field of type date is a data time field.
Anyone got this problem?
Of course the date in the other json objects are not correct, but 4D received
the value and display the correct date for me (10-12-2018) so I’m going to
aspect to find all 3 records with the first query.
Obviously now I correct the json date in the json string in order to fix the
problem, but if someone is going to send me a big json with dates as the first
two json objects I will get wrong dates in all records on my 4D data file that
will be very hard to catch.
If the json value is wrong like text or number the date on the field will be
00-00-00 that is ok for me. It’s mean that the date format is wrong.
json to selection is a great feature in 4D, I can get data from a json string
very quickly but in this case I need to check all properties that should fill
date fields and correct the time values if not T00:00:00.000Z.
Thanks in advance
Andrea Angeli
-------------------------------------------------------------------
Alfanet srl [email protected]
viale Europa, 62 http://www.alfanet.it/
00144 Rome (IT)
tel. +39 06 5924665
fax +39 06 5923352
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************