🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #23845

Re: SQL, Dates and MS Access Databases

#23845
From: Will Stranathan
Date: Sun, 16 Sep 2001 20:58
68 lines
4440 bytes
Hmmm...that doesn't sound right for OLE dates.  Day 0 should be 
01/01/1900, and progress forward, 1 for each full day.  So 0.75 is 6PM 
on 01/01/1900.

I'd probably use an SQL insert statement to do the insert, and represent 
the string in human-readable format, delimited by #'s.  For example, 
#Jan 23, 2014# .  I don't know if I'd try to go the route of calculating 
compared to a Java date.

When extracting the information from the db, I'd use the Access date 
functions (DateDiff and so forth) to construct the date into a string 
format.

My sincerest sympathies since you have to use Access.  One would think 
that the ODBC driver would properly change the format of the date, (or 
maybe that is "property formatted", but other ODBC hasn't given me issues.)

So long story short, don't use Date variables - use string manipulation 
to put things together in a common readable format.

Will Stranathan

Randy K. Secrist wrote:

> Help!
> 
> Does anyone know how to get the number of exact days since or before a
> specific time period?  If you think you can help, let me describe what I am
> doing below...
> 
> I am inserting rows into an access database.  One of the columns I am adding
> is a date field.  Normally using Oracle or DB2, I can instantiate a
> java.util.Date, and insert the variable directly in the insert statement,
> and the correct date gets inserted into the database.
> 
> However, in this case, the people I am doing a program for are set on using
> MS Access.  *Sigh*.  The driver throws an exception if I use a
> java.util.Date, and if I use a java.sql.Date it successfully inserts the
> field into the database, but the wrong date is added to the row.  So, after
> experimenation, i noticed that to get the correct date into the database,
> the SQL insert statment must have the date fields is just really a regular
> integer that looks like this:
> 
> 0 being December 30 1899
> 1 being December 31 1899
> 2 being Jan 01, 1900
> 3 being Jan 02, 1900 etc.
> 
> 25569 being Jan 01, 1970
> 
> Since java tracks time in miliseconds from Jan 01 1970 - 12:00 AM being
> around 2703600000 miliseconds, i started to do  this the hard way - to get
> the number of days since 01/01/1900 from the number of miliseconds since
> 1970 - writing all kinds of methods to divide and get the miliseconds right.
> 
> So far this work around seems to work for 1900 to 2100 years, but if I go
> back far in time, say to 1700 it starts getting off by a few days.  For all
> i know it has to do with leap years, and the such.  Basically I don't want
> to write a whole date class just to get the number of days... does anyone
> have solutions that could save me a lot of time and hassle?  I'd really
> appreciate it....
> 
> Randy Secrist
> 
> 
> 
> 
> 
Technical Details
Message-ID: <3BA513AB.5010508@thestranathans.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn4feed!worldnet.att.net!24.0.0.38!newshub2.rdc1.sfba.home.com!news.home.com!news2.rdc2.tx.home.com.POSTED!not-for-mail
References: <zC3p7.63$%W3.128769@news.uswest.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d6b,5e897627a3332cb9
X-Google-Attributes: gid111d6b,public
X-Google-Thread: 10a146,5e897627a3332cb9
X-Google-Attributes: gid10a146,public
X-Google-Thread: f5d71,5e897627a3332cb9
X-Google-Attributes: gidf5d71,public
X-Google-Thread: f6cb0,5e897627a3332cb9
X-Google-Attributes: gidf6cb0,public
X-Google-Thread: 113ae9,5e897627a3332cb9
X-Google-Attributes: gid113ae9,public
X-Google-ArrivalTime: 2001-09-16 13:58:21 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn4feed!worldnet.att.net!24.0.0.38!newshub2.rdc1.sfba.home.com!news.home.com!news2.rdc2.tx.home.com.POSTED!not-for-mail
Message-ID: <3BA513AB.5010508@thestranathans.com>
From: Will Stranathan <will@thestranathans.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1
X-Accept-Language: en-us
MIME-Version: 1.0
Newsgroups: cn.bbs.comp.lang.java,comp.lang.java,comp.lang.java.help,comp.lang.java.misc,comp.lang.java.programmer
Subject: Re: SQL, Dates and MS Access Databases
References: <zC3p7.63$%W3.128769@news.uswest.net>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 69
Date: Sun, 16 Sep 2001 20:58:20 GMT
NNTP-Posting-Host: 24.179.101.120
X-Complaints-To: abuse@home.net
X-Trace: news2.rdc2.tx.home.com 1000673900 24.179.101.120 (Sun, 16 Sep 2001 13:58:20 PDT)
NNTP-Posting-Date: Sun, 16 Sep 2001 13:58:20 PDT
Organization: Excite@Home - The Leader in Broadband http://home.com/faster