leegold wrote:
> Hi,
>
> Given an MS-Access table with a date type field with a value of:
> 12:00:00 AM - just"12:00:00 AM", there's nothing else in the field.
>   
As you note later nothing "visible" If you run the following query:
SELECT Year([field1]) AS Expr1, Month([field1]) AS Expr2, Day([field1]) 
AS Expr3, Hour([field1]) AS Expr4, Minute([field1]) AS Expr5, 
Second([field1]) AS Expr6
FROM Table1

You will get 1899 12 30 0 0 0. That is what is in the field. That date 
is the "epoch" or starting time for date time values. Access suppresses 
the display of YMD for 1899 12 30 so it can have a way to store a "time 
only" values.

So you need to test for this date and treat it differently from all 
other dates.
> I want to print exactly what's in the field, ie. "12:00:00 AM". What I
> get printed is:   12/30/0/ 00:00:00
>
> I try:
>
> import win32com.client
> from win32.client import Dispatch
>
> oConn=Dispatch('ADODB.Connection')
> db = r'C:\mydb.mdb'
> oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0; data Source="+db)
> oRS = Dispatch('ADODB.RecordSet')
> oRS.ActiveConnection =  oConn
> c = oConn.OpenSchema(20)
>
> while not c.EOF:
>     tn = c.Fields.Item('Table_Name').Value
>     oRS.Open(tn)
>     (oRS, dt) = oConn.Execute('SELECT date_field FROM '+tn+' GROUP BY
>     date_field')
>     while not oRS.EOF:
>         print oRS.Fields(dt).Value  # print here
>          oRS.MoveNext()
>     c.MoveNext()
>
> oRS.Close()
> oConn.Close()
> # end
>
> What's printed is:   12/30/0/ 00:00:00
>
> How do I get exactly what's in the field? Note, there could be any legal
> date time in the field - I'm trying in all cases to get exactly what's
> in the field...or to put it another way, exactly what I see when I open
> Access and look.
>
> Thanks very much,
>
> Lee G 
> _______________________________________________
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>   


-- 
Bob Gailer
919-636-4239 Chapel Hill, NC

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to