Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TSQL date field (name)

Posted on 1998-10-06
12
Medium Priority
?
164 Views
Last Modified: 2010-04-06
How can I retreive data from a field who fieldname is an reserved word ( Date, Time, etc.)
0
Comment
Question by:lortega
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342013
Hi lortega,

Label1.Caption := Table1.FieldByName('Date').AsString;
or
Label1.Caption := Table1.FieldByName('Date').AsInteger;
or
.

Regards, Zif.
0
 
LVL 1

Expert Comment

by:tha_incredible_bo
ID: 1342014
hi Iortega,

try to put the name of the field in double-quotes e.g. select "Date" from ... or if you are working with an SQL-Server: select tablename.Fieldname from ...
0
 
LVL 2

Author Comment

by:lortega
ID: 1342015
I need something like...

Select * from myTable Where Date = '8/4/98'

where Date is the name of the field...

note on Oracle or MSSQL you should write the fieldname between brackets  []...
Select * from myTable Where [Date] = '8/4/98'

but who to do this on Delphi (TQuery)?

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Author Comment

by:lortega
ID: 1342016
tha_incredible_bo set your awnser, because is a mix of your awnser...


Select * from myTable Where HistoryDB."Date" = '8/4/98'

note:
Select * from myTable Where "Date" = '8/4/98'    // Don't work
Select * from myTable Where HistoryDB.Date = '8/4/98'   // Don't work


thank's
lortega
0
 
LVL 2

Author Comment

by:lortega
ID: 1342017
tha_incredible_bo set your awnser, because is a mix of your awnser...


Select * from myTable Where HistoryDB."Date" = '8/4/98'

note:
Select * from myTable Where "Date" = '8/4/98'    // Don't work
Select * from myTable Where HistoryDB.Date = '8/4/98'   // Don't work


thank's
lortega
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342018
Ok, now I understand what you want.

doesn't this works :

Select *
from MyTable M
where M.Date = 'Snapper'

Regards, Zif


0
 
LVL 10

Expert Comment

by:Jacco
ID: 1342019
Changing the fieldname is not an option I suppose?

I use dates with a prefix:

Arrival_Date
Depart_Date
Trace_Date
Action_Date
Orig_Date
etc.

Regards Jacco
0
 
LVL 1

Accepted Solution

by:
tha_incredible_bo earned 90 total points
ID: 1342020
hi Iortega,

I tried to write a little bit code concerning your problem and found the following result:

with this sql-statement select * from "f:\pdoxdb\test" where "date" ="" everything is allright (concering the date field). the only thing you must pay attention (for correct results) is the format of your date-field! this belongs to your database-type. e.g. some databases use an internal date format and so you have to cast your input date (10.10.98) to this internal format (sometimes) - so please be careful.

cu
Bo
0
 
LVL 2

Author Comment

by:lortega
ID: 1342021
Jacco if I change the fieldname, I have to go tru all our clients... and we are not MS  :-)
but this kind of thinks help us in the future.

ZifNab your solution works if I use MS database, but I don't know why don't work here  :-(

tha_incredible_bo I realy don't know who create this database, but the fieldname is Date and the field format is character (string)... hummmmm...

thanks
luis
0
 
LVL 1

Expert Comment

by:tha_incredible_bo
ID: 1342022
hi Iortega,

very strange field-format, isn't it ???? Try to find the one who defined the database structure and the field-formats and buy him a lollypop ... :-)))

Do you leave the format unchanged or will you change it??? If you leave the format there should be a format-procedure which should insure an everytimes equal format result before writing to the database except you will sooner or later run into troubles (inconsitency or wrong search results) !!!

CU
Bo


0
 
LVL 2

Author Comment

by:lortega
ID: 1342023
We don't have permison to change fields until next version or release :-(
but I wil take care of that...

thanks
luis
0
 
LVL 1

Expert Comment

by:tha_incredible_bo
ID: 1342024
bad luck Iortega! think about the procedure (if it is not too late)?!

keep it up
CU
Bo ;-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question