On Aug 27, 2016, at 2:00 PM, Arnaud de Montard wrote:

> since v11 I think this is wrong, see the number of bytes of some 4D fields:
> <http://screencast.com/t/eRDzgw0BNZ9>
> Both date and hour types are 8 bytes whereas if we where still in the 
> before-v11-situation, date should be 6 (2*3) and hour should be 4 (same as a 
> longint, which explains the selection to array(hourField;longintArray)). 
> This (added to some strange things happening in SQL queries on date fields, 
> example <http://forums.4d.fr/Post/FR/16272092/0/0/>) makes me think that this 
> 8 byte storage is a timestamp (date+hour), still not "revealed" by 4D for 
> compatibility reasons. Pure speculation, of course.

Very good catch Arnaud. I was not aware of the change in size for date and time 
fields. So now we have to wonder about the reason for the change in size. I’ll 
speculate too. :) Possible design decisions:

1. Faster and easier to read 8 bytes than to read 6 bytes, so read 8 and only 
use 6 to store the date in the same format as before as integers: 2 bytes for 
year, 2 bytes for month, 2 bytes for day.

2. Store a “timestamp” in the 8 bytes in some alpha format like YYYYMMDDHHMMSS 
and have 2 bytes left over. Sort of a compressed UTC type format. 

3. Store a “timestamp” in the 8 bytes in the form of 2 longints. First one is 
the number of days since some epoch and second one for time. 

That would give you a very large range of dates to be able to store. Say you 
started at Jan. 1, 0AD. Aug. 28, 2016 would only be 736,203 days. You could go 
crazy and say start at 10,000BC and go to 10,000AD and that’s only 7,304,724 
days.  http://www.planetcalc.com/274/ 

In the second longint, store number of milliseconds in a day. That’s 86,400,000 
milliseconds per day. Very good precision for storing a time value, and easy to 
store in a longint. 

The problem with using a longint for a timestamp like unix does is you start at 
00:00:00 on Jan 1, 1970, so you can’t easily store dates prior to that. And you 
can’t store values past 03:14:07 on Jan 19, 2038. 

I’ll now include the 3 “magic characters" JPR in this post to trigger his email 
filter to flag this post as something he might be interested in reading. Being 
the author of DataAnalyzer I bet he knows the new 4D v11 date and time formats. 

Do you know JPR?

Tim

********************************************
Tim Nevels
Innovative Solutions
785-749-3444
[email protected]
********************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to