Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TSQL date field (name)

Posted on 1998-10-06
12
Medium Priority
?
165 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
  • 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
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.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

886 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