Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > Database & Database Programming

Database & Database Programming MySQL, Oracle, SQL, PL/SQL, ABAP, Smart Forms, and other databases and languages. A database is an organized body of related information used in many websites (including CC).

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-2007, 05:56 PM
ashleysmithd's Avatar   
ashleysmithd ashleysmithd is offline
Newbie
 
Join Date: Apr 2007
Posts: 9
Rep Power: 0
ashleysmithd is on a distinguished road
Question Selecting records with a condition

Hi.

Slightly amateur question here (I'm new to SQL)

In Delphi, in using the ODBC, I'm trying to bring up a list of records that contain a 'date + time' attribute, that are smaller than the current date.

And is there anyway to bring up separate attributes such as 'first name' and 'surname' that correspond to the record being shown?

Sorry for such a basic question, I've just started learning SQL, and need it to complete my coursework.

Any help would be appreciated, thanks.

Last edited by ashleysmithd; 04-19-2007 at 06:36 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-20-2007, 09:44 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,224
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Hello,
Without knowing the table structure and the date/time format (is it Unix Timestamp?) it may look something like this:

Code:
SELECT tbl.firstname, tbl.surname
FROM tbl AS tbl
WHERE date < SYSDATE;
If you give me the table structure and more info (like what SQL client you are using - MySQL, Access, msSQL, etc.) I can help you further.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2007, 04:54 PM
ashleysmithd's Avatar   
ashleysmithd ashleysmithd is offline
Newbie
 
Join Date: Apr 2007
Posts: 9
Rep Power: 0
ashleysmithd is on a distinguished road
Default

Quote:
Originally Posted by Jordan View Post
Hello,
Without knowing the table structure and the date/time format (is it Unix Timestamp?) it may look something like this:

Code:
SELECT tbl.firstname, tbl.surname
FROM tbl AS tbl
WHERE date < SYSDATE;
If you give me the table structure and more info (like what SQL client you are using - MySQL, Access, msSQL, etc.) I can help you further.
Hi Jordan, thanks for the reply.

I'm using the ODBC feature in Delphi 5. I'm building the database into my software.

I built the database using Access, but exported it into a .DB format, a paradox database format if I can remember correctly.

At the moment I can successfully execute queries and return data. However, only to a degree.

This is basically what I want to do:

Code:
SELECT TimeDateIn, FirstName, Surname
FROM orders.DB
WHERE TimeDateIn < SYSDATE
I've managed to get the multiple fields working, because of the code you posted, thankyou for that. But I'm having some difficulty getting the 'SYSDATE' to work. It just comes up with 'Invalid Field Name', as if it doesn't recognise the line atall.

Once again, thankyou for your time.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-24-2007, 09:46 AM
ashleysmithd's Avatar   
ashleysmithd ashleysmithd is offline
Newbie
 
Join Date: Apr 2007
Posts: 9
Rep Power: 0
ashleysmithd is on a distinguished road
Default

Anyone?

Sorry for bumping the thread but I need to hand this project in in a few weeks time and I'm getting really desperate about it now. All I need to do is get some SQL querys working.

I think I've figured out what date function Delphi 5 understands, CURRENT_DATE(). However it says that the compatability is not supported.

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-24-2007, 12:55 PM
ashleysmithd's Avatar   
ashleysmithd ashleysmithd is offline
Newbie
 
Join Date: Apr 2007
Posts: 9
Rep Power: 0
ashleysmithd is on a distinguished road
Default

A quick update,

I spoke to a fellow student today, and he has told me that it won't work by comparing the database attribute with an SQL function such as current_date().

Apparently, I have to set a variable inside the 'params'. And compare the variable with the database attribute.

The only problem is... The button to add a new param is greyed out. And I can't see anything obvious to change that.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 04-26-2007, 10:31 AM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Rep Power: 13
NeedHelp is on a distinguished road
Default

So basically the SYSDATE cannot be used in a "Where"? Couldn't you do that in the SQL too?

Code:
SELECT variable, SYSDATE AS myDate
..........
WHERE TimeDateIn < myDate;
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-01-2007, 01:31 PM
WillB's Avatar   
WillB WillB is offline
Learning Programmer
 
Join Date: Apr 2007
Location: St. Cloud, Fl
Age: 19
Posts: 43
Rep Power: 6
WillB is on a distinguished road
Default

Quote:
Originally Posted by NeedHelp View Post
So basically the SYSDATE cannot be used in a "Where"? Couldn't you do that in the SQL too?

Code:
SELECT variable, SYSDATE AS myDate
..........
WHERE TimeDateIn < myDate;
I agree, it should work in the SQL

If you look around some of the documentation on ODBC it may have another method listed...
__________________
Everything in Life can be solved with an 'If/Else' statement.

Life is like one big try/catch statement, nested within a loop.

-Will

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-05-2007, 02:54 PM
ashleysmithd's Avatar   
ashleysmithd ashleysmithd is offline
Newbie
 
Join Date: Apr 2007
Posts: 9
Rep Power: 0
ashleysmithd is on a distinguished road
Default

Unfortunately nothing came up, however it doesn't matter as I'm just going to write it in, the examiner isn't going to have a copy of the software itself. So he/she won't know it doesn't work.

Anyway, thanks the replies guys it is appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts and Hibernate: Error retrieving records from the DB :-[yc]-: Java Help 3 05-17-2007 01:45 PM
getting the value of checkboxes to delete the records in the sql table pavsuri ASP, ASP.NET and Coldfusion 1 05-07-2007 03:10 PM


All times are GMT -5. The time now is 11:31 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads