sjmachin at lexicon.net
Mon Feb 2 10:17:32 CET 2009
On Feb 2, 7:29 pm, Gilles Ganault <nos... at nospam.com> wrote:
> I have data in an SQL database where one column contains a date
> formated as DD/MM/YYYYY.
> I need to select all rows where the date is before, say Feb 1st 2009,
> ie. 01/02/2009.
> Is there a command in Python that does this easily, or should I look
> into whatever date() function the SQL database offers?
It would help if you told us:
(1) Which database software
(2) What type that column was declared to be in the CREATE TABLE
(3) Whether you have used the Python DB API on a database before
(4) Whether you have used a stand-alone SQL query tool on a database
(5) How you came to the conclusion that one column contains a date
formatted as dd/mm/yyyy ... Only one? Are there other date-containing
columns in the same table or other tables in the database? If so, how
are they formatted?
Basically, you are going to have to execute some SQL like:
SELECT * FROM the_table WHERE the_date < '2009-02-01'
which a reasonable chance of being syntactically valid and giving the
correct answer, if the column type is DATETIME/DATE/TIMESTAMP/similar.
If it's CHAR/VARCHAR/TEXT/CHARACTER/similar, then it's going to be
harder, and will depend on what database software it is.
A really silly question: have you asked the database administrator
More information about the Python-list