[Tutor] Dates

Alan Gauld alan.gauld at btinternet.com
Sun Sep 10 18:55:07 CEST 2006


> a = datetime.date(2006,01,31)
> b = datetime.date(2006,12,31)
> c = str(a)
> d = str(b)

I'm not sure what format your data base expects for dates
but given you used the SQL date function before I'd go for
that again. Just pass the string equivalent of your dates
into the SQL date function. You probavly don;t need the
datetime stuff above at all.

> Is there another way I can approach this problem?  Say if I use
> something like:
>
> c.execute('SELECT * FROM times where rt_weekst >= date(?) and 
> rt_weekst
> <= date(?)  and rt_type == ?', (c,d,"R",))

Yes this is what I mean but to male it work c and d need to be in
the same format you had before, something like

c = "2006,01,31"

That will then be inserted into the query string.
I'm not sure if it will work like that, you may need
to split it into 3 separate parameters.

> Driver]Too few arguments.', 4579)

I think thats because it sees the x-y-z format as an arithmetic
sum or as a single non standard string.

ButIi'm guessing a bit here as I've never used the ODBC driver nor 
Foxbase.

HTH,

Alan G. 




More information about the Tutor mailing list