Solved

Local SQL select for date=today

Posted on 2006-07-11
16
2,126 Views
Last Modified: 2008-01-09
Hi team,

I'm trying to limit my extract from two tables to those records where ufsale = today

SELECT (trim(both " " from key1)+"/0 "+ g1.company) as receivercompany,
ulocname as locationname,
g1.zip as costcentre,
g1.contact as receiverattn,g1.phone1 as receiverph,
g1.address1,
g1.address2,
g1.city as address3
from Contact1 g1, contact2 g2
where g1.accountno =g2.accountno
and ufsale=getdate()

Using Access or SQL Server this would work fine, but for Local SQL what is the syntax for where ufsale=today?

Urgent help required for a simple question, note it is "Local SQL" as in Paradox,xBase

All help is appreciated.



Cheers
Bernard
0
Comment
Question by:BernardGBailey
  • 7
  • 4
  • 2
  • +2
16 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17085629
>and ufsale=getdate()

and ufsale>= convert(datetime, convert(varchar(10), getdate(), 120), 120)
and ufsale< dateadd(day, 1,convert(datetime, convert(varchar(10), getdate(), 120), 120))
0
 

Author Comment

by:BernardGBailey
ID: 17085693
Hi AngelIII,

No joy with either,

Invalid use of keyword
Token:varchar(10)

I like the speed of response though :)

Cheers
Bernard
0
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17085809
SELECT (trim(both " " from key1)+"/0 "+ g1.company) as receivercompany,
ulocname as locationname,
g1.zip as costcentre,
g1.contact as receiverattn,g1.phone1 as receiverph,
g1.address1,
g1.address2,
g1.city as address3
from Contact1 g1, contact2 g2
where g1.accountno =g2.accountno
and ufsale=current_date
0
 

Author Comment

by:BernardGBailey
ID: 17085836
Hi sathyagiri,

>and ufsale=current_date

Local SQL thinks current_date is a field so it comes up "invalid fieldname"

Sorry,

Cheers
bernard
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17085848
I see I overlooked that. Ignore my post, please
0
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17085861
Current_date is a function, so try current_date()
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 17085898

For "Local SQL", the date function may be different (on Paradox, xBase and FoxPro it's DATE()).

If you want to code "generic" SQL, you would need to create a 'getdate()' function for each those DB's that have another name for this function.


0
 

Author Comment

by:BernardGBailey
ID: 17085933
Hi sathyagiri.

>and ufsale=current_date()

"capability not supported"

Cheers
Bernard
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:BernardGBailey
ID: 17085961
Hi MikeOM,

>and ufsale=DATE()

"Invalid use of keyword"

I already tried this, sorry.

Cheers
Bernard
0
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17085992
What is the version of your LOCAL SQL?
0
 

Author Comment

by:BernardGBailey
ID: 17086147
Hi Sathyagiri,

I'm using database tour.

Cheers
bernard
0
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17086217
Try using just DATE instead of DATE()
0
 

Author Comment

by:BernardGBailey
ID: 17086261
Hi Sathyagiri,

>and ufsale=DATE

"Invalid use of keyword
Token:DATE"

I guess this means there is another format of DATE we haven't arrived at yet.

Cheers
Bernard
0
 

Expert Comment

by:suhinrasheed
ID: 17088934
TRY and ufsale=sysdate

or

check if above is not wrking

ufsale=(select sysdate from dual)
0
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 500 total points
ID: 17090546

It seems the Database Toour utlility is the culprit due to the fact that it will not recognize the DATE function for some of the databases.

Therefore you may want to use a parameter and supply the value at execution time:

SELECT (trim(both " " from key1)+"/0 "+ g1.company) as receivercompany,
             ulocname as locationname,
             g1.zip as costcentre,
             g1.contact as receiverattn,g1.phone1 as receiverph,
             g1.address1,
             g1.address2,
             g1.city as address3
     from Contact1 g1, contact2 g2
   where g1.accountno =g2.accountno
      and ufsale=:DATE

0
 

Author Comment

by:BernardGBailey
ID: 17105781
Hi MikeOM_DBA

Thnaks this will do in the meantime until I can get Vitaly to fix the issue.

Cheers
Bernard
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction: Often, when running a query with joins, the results show up "duplicates", and often, those duplicates can be "eliminated" in the results using DISTINCT, for example. Using DISTINCT is simple: just add it after the SELECT keyword, an…
In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

709 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now