473,698 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Representing ambiguity in datetime?

What do you do when a date or time is
incompletely specified? ISTM, that as it is, there is no
formal way to store this --- you have to guess, and there's
no way to indicate that the guess is different from solid
information. As a result, I have sometimes had to abandon
datetime, even though it seemed like the logical choice for
representing data.

E.g. I might have information like "this paper was published
in May 1997". There's no way to write that with datetime,
is there? Even if I just use the "date" object instead of
datetime, I still have to actually specify something like
May 1, 1997 --- fabricating data, which is frequently
undesireable (later on, I might find information saying that
it was actually published May 23, 1997 and I might want
to update the earlier one, or simply evaluate them as
"equal" since they are, to within the precision given ---
for example, I might be trying to decide that two database
entries are really duplicate references to the same paper).

I know that this is somewhat theoretically stated, but I
have run into to concrete problems along the lines of
the above.

I'd say this is analogous to how you might use "None"
rather than "0" to represent an integer if you don't know
it's value (rather than knowing that it is zero). ISTM, you
ought to be able to specify a date as, e.g.:

d = datetime.date(2 005, 5, None)

I realize there might be some complexity with deciding
how to handle datestamp math, but as this situation
occurs frequently in real life, it seems like it shouldn't
be avoided.

How do other people deal with this kind of problem?

Cheers,
Terry

--
Terry Hancock ( hancock at anansispacework s.com )
Anansi Spaceworks http://www.anansispaceworks.com

Jul 19 '05 #1
6 1674
On Tue, 17 May 2005 17:38:30 -0500, Terry Hancock
<ha*****@anansi spaceworks.com> wrote:
What do you do when a date or time is
incompletely specified? ISTM, that as it is, there is no
formal way to store this --- you have to guess, and there's
no way to indicate that the guess is different from solid
information. As a result, I have sometimes had to abandon
datetime, even though it seemed like the logical choice for
representing data.

E.g. I might have information like "this paper was published
in May 1997". There's no way to write that with datetime,
is there? Even if I just use the "date" object instead of
datetime, I still have to actually specify something like
May 1, 1997 --- fabricating data, which is frequently
undesireable (later on, I might find information saying that
it was actually published May 23, 1997 and I might want
to update the earlier one, or simply evaluate them as
"equal" since they are, to within the precision given ---
for example, I might be trying to decide that two database
entries are really duplicate references to the same paper).

I know that this is somewhat theoretically stated, but I
have run into to concrete problems along the lines of
the above.

I'd say this is analogous to how you might use "None"
rather than "0" to represent an integer if you don't know
it's value (rather than knowing that it is zero). ISTM, you
ought to be able to specify a date as, e.g.:

d = datetime.date(2 005, 5, None)

I realize there might be some complexity with deciding
how to handle datestamp math, but as this situation
occurs frequently in real life, it seems like it shouldn't
be avoided.

How do other people deal with this kind of problem?


Mostly, badly :-(

Real-life example: due to war-time disruption etc, in some countries
it is common enough to find that the date of birth of someone born in
the 1940s is not known precisely. E.g. on the Hong Kong identity card,
it is possible to find only the year and month of birth, and sometimes
even only the year. Depending on the purpose, legislation and
convention will take the first day of the vague period or the last day
when a calculation is required. Badly == entering into a database the
"exact" date that was used for the purpose du jour, with no indication
that the source was vague. Consequently a person can have DOB recorded
as 1945-01-01 on one database and 1945-12-31 on another.

Suggested approach in Python (sketch): Don't try to get the datetime
module to solve the problem. Define a fuzzydate class. Internal
representation: I'd suggest earliest possible date and latest possible
date. That way you have valid date instances for doing date
arithmetic. May have different constructors depending on how the
incoming vagueness is specified.

HTH,
John
Jul 19 '05 #2
John Machin wrote:
On Tue, 17 May 2005 17:38:30 -0500, Terry Hancock
<ha*****@anansi spaceworks.com> wrote:

What do you do when a date or time is
incompletel y specified? ISTM, that as it is, there is no
formal way to store this --- you have to guess, and there's
no way to indicate that the guess is different from solid
information . As a result, I have sometimes had to abandon
datetime, even though it seemed like the logical choice for
representin g data.

E.g. I might have information like "this paper was published
in May 1997". There's no way to write that with datetime,
is there? Even if I just use the "date" object instead of
datetime, I still have to actually specify something like
May 1, 1997 --- fabricating data, which is frequently
undesireabl e (later on, I might find information saying that
it was actually published May 23, 1997 and I might want
to update the earlier one, or simply evaluate them as
"equal" since they are, to within the precision given ---
for example, I might be trying to decide that two database
entries are really duplicate references to the same paper).

I know that this is somewhat theoretically stated, but I
have run into to concrete problems along the lines of
the above.

I'd say this is analogous to how you might use "None"
rather than "0" to represent an integer if you don't know
it's value (rather than knowing that it is zero). ISTM, you
ought to be able to specify a date as, e.g.:

d = datetime.date(2 005, 5, None)

I realize there might be some complexity with deciding
how to handle datestamp math, but as this situation
occurs frequently in real life, it seems like it shouldn't
be avoided.

How do other people deal with this kind of problem?

Mostly, badly :-(

Real-life example: due to war-time disruption etc, in some countries
it is common enough to find that the date of birth of someone born in
the 1940s is not known precisely. E.g. on the Hong Kong identity card,
it is possible to find only the year and month of birth, and sometimes
even only the year. Depending on the purpose, legislation and
convention will take the first day of the vague period or the last day
when a calculation is required. Badly == entering into a database the
"exact" date that was used for the purpose du jour, with no indication
that the source was vague. Consequently a person can have DOB recorded
as 1945-01-01 on one database and 1945-12-31 on another.

Suggested approach in Python (sketch): Don't try to get the datetime
module to solve the problem. Define a fuzzydate class. Internal
representation: I'd suggest earliest possible date and latest possible
date. That way you have valid date instances for doing date
arithmetic. May have different constructors depending on how the
incoming vagueness is specified.

HTH,
John

This is a very common problem in genealogy research as well as other
sciences that deal with history, such as geology, geography, and archeology.

I agree that some standard way of dealing with fuzzy dates would be a
good thing. I think looking at how others do it would be the way to
start...

A google search found the following reference buried in a long reference
page on mysql.

http://www.dreamlink.net/mysql/manual_Functions.html
The reason the ranges for the month and day specifiers begin

with zero is that MySQL allows incomplete dates such as
'2004-00-00' to be stored as of MySQL 3.23.
So it seems using 0's for the missing day or month may be how to do it.

Cheers,
_Ron
Jul 19 '05 #3
Hi All--

Ron Adam wrote:

John Machin wrote:
On Tue, 17 May 2005 17:38:30 -0500, Terry Hancock
<ha*****@anansi spaceworks.com> wrote:

What do you do when a date or time is
incompletel y specified?
The reason the ranges for the month and day specifiers begin

with zero is that MySQL allows incomplete dates such as
'2004-00-00' to be stored as of MySQL 3.23.

So it seems using 0's for the missing day or month may be how to do it.


This is somewhat the approach I took in order to allow users to specify
an incomplete Mayan date in order to list possibilities. But instead of
0 (which is a valid entry in most Mayan date components), I used None.
The web version can be found at

http://www.pauahtun.org/Calendar/tools.html (the "Search for Matching
Dates" button)

The paper describing the incomplete Mayan date tool is at:
http://www.pauahtun.org/python_vuh.html

Metta,
Ivan
----------------------------------------------
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/worksh...oceedings.html
Army Signal Corps: Cu Chi, Class of '70
Author: Teach Yourself Python in 24 Hours
Jul 19 '05 #4
Terry Hancock wrote:
What do you do when a date or time is
incompletely specified?


Doesn't the answer to this pretty much entirely depend on how you are
going to make use of the information? What are your use cases?
Jul 19 '05 #5
Ron Adam wrote:
This is a very common problem in genealogy research as well as other
sciences that deal with history, such as geology, geography, and archeology. .. So it seems using 0's for the missing day or month may be how to do it.


Except of course humans like to make things more complicated than that.
Some journals are published quarterly so an edition might be "Jan-Mar".
Some countries refer to week numbers, so an event might be in "week 12".

I offer no suggestions as to how to handle these cases.

Andrew
da***@dalkescie ntific.com

Jul 19 '05 #6
Ron Adam <rr*@ronadam.co m> writes:
So it seems using 0's for the missing day or month may be how to do it.


This doesn't allow more specific amounts of ambiguity. I suggest
either a pair of dates, which represent the earliest and latest that
the event could have been (and are equal if there is no ambiguity),
or a date plus a number of days of uncertainty, i.e.
21 June 2005 +- 5 days.

Dan
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1713
by: Rajeev | last post by:
Hi I have a table in SQL Server 2000 that has following data: PunchTime PunchType 11:45:00 In 12:45:00 Out 1:45:00 In 3:15:00 Out Is there a way in SQL to represent this in the following format:
2
24647
by: Pet Matrix. | last post by:
Hi, I am having the schema and one element in that schema is , <xs:element name="EndT" type="TstampType" minOccurs="1" maxOccurs="1"/> How do I represent the NULL value for the datatype dateTime in the xml.
4
1263
by: reidarT | last post by:
I want to show data objects as Y-axis (rows) and dates alng x-axis (fields) Date 01.01.05 02.01.05 03.01.05 ... Obj1 Free Free Occupied Obj2 Free Occupied Free Obj3 Occupied Free Occupied .... I wouldn't like to make a table with Dates as fields ( I need more than 2 years ahead)
0
1529
by: ciaran.mchale | last post by:
I used Google to find information about JAXB 2.0 and I ended up downloading a document called "The Java Architecture for XML Binding (JAXB) 2.0: Proposed Final Draft September 30, 2005". Section D.2 (pages 331 to 334) gives an unambiguous explanation of the mapping from an XML name into a Java identifier *if* the underscoreHandling is "asWordSeparator" (which is the default). In particular, Table D-1 uses regular expressions to clearly...
3
1640
by: subramanian100in | last post by:
I have tried the following in VC++ 2005 Express Edition and g++ in Linux. Consider the class class my_complex { public: my_complex(double r, double i = 10.0) : re(r), im(i) { } my_complex(double r) : re(r), im(0) { }
4
2103
by: DaTurk | last post by:
Hi, I only need to represent the time, not the day. Is there any other structure I can use beside DateTime? Because the constructor doesn't have the ability to take the time alone. Thanks
2
1726
by: subramanian100in | last post by:
Consider the program #include <iostream> using namespace std; void fn(const char * str, char x = 'Y') { cout << "from fn(const char *, char) - " << str << endl; return;
10
2199
by: subramanian100in | last post by:
consider the following program: #include <iostream> using namespace std; class my_complex { public: friend ostream & operator<<(ostream &os, const my_complex &c);
4
3374
by: abendstund | last post by:
Hi, I have the following code and trouble with ambiguity due to operator overloading.. The code is also at http://paste.nn-d.de/441 snip>>
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.