Queriong a table with a column named "Date"

welid

New member
Local time
Today, 11:41
Joined
Nov 27, 2007
Messages
4
Hello,

I'm trying to query excel file which contains a column named "Date",
so when I'm trying to do a query like "select * from Table_Name" it's working fine, and I'm getting all the data including the column named Date, but when I'm doing any query which is referencing "Date" I'm getting an error "Syntax error in date in query expression"
This is due-I think- to the fact that Date is a reserved word...but when I'm trying to change the column name Date to anything else say "Date_Debut"
the problem is still there, so is there any special thing to do when querying Date column type?
Please help!
Thanks,
welid
 
You're right about why the problem is happening, have you tried enclosing the column name in brackets like "SELECT [Date] FROM MyTableName;" the only other resolution I can think of is to alter the Excel file and change its column name.
 
You're right about why the problem is happening, have you tried enclosing the column name in brackets like "SELECT [Date] FROM MyTableName;" the only other resolution I can think of is to alter the Excel file and change its column name.

Thanks for answering,

Yes I did try to change the column name to "Date_debut" and same problem I'm getting,
Also tryed to put Date between brackets but still same error.
 
what are you trying to query from date_debut? you have to make sure to enclose your date in # #
 
what are you trying to query from date_debut? you have to make sure to enclose your date in # #
Actually, I gave the "Date" column name with a name which is "date_debut" to find wether it's related to the fact that I'm used a reserved word,
but it seems that's not the case because I'm getting the same error message again,
so maybe it's coming from syntax, how do you retrieve a column with a Datetime Datatype?
 
Its just the same as retrieving other values. Just remember you need to enclose a literal date with # signs.

Can you post your DB so we can look at it.
 
Its just the same as retrieving other values. Just remember you need to enclose a literal date with # signs.

Can you post your DB so we can look at it.

I didn't find how to upload the file along with the message,can someone tell me?

here is the table structure (the DB is only one table)
Tonage(N°, Date, Heure, Immat, Client, Zone, Chauff, Type dech,Brut,Tare,Net)
 
You see, Excel isn't at all fussy about datatypes, but Access is. Your date may look like a date/time but it could be text. You may be able to use CDate() to convert the text value to a true date/time.
 
Neil beat me to this one. Excel is so fussy about date types that I almost NEVER get it to convert those types to Access dates. You also have to remember that what Excel really stores isn't what you see anyway. You see what Excel chooses as a format.
 
Neil beat me to this one. Excel is so fussy about date types that I almost NEVER get it to convert those types to Access dates. You also have to remember that what Excel really stores isn't what you see anyway. You see what Excel chooses as a format.

which is retarded

thats what i really really dislike about excel
 

Users who are viewing this thread

Back
Top Bottom