Solved

Local SQL select for date=today

Posted on 2006-07-11
16
2,135 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

929 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

11 Experts available now in Live!

Get 1:1 Help Now