Solved

Local SQL select for date=today

Posted on 2006-07-11
16
2,170 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
[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
  • 7
  • 4
  • 2
  • +2
16 Comments
 
LVL 143

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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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 143

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
 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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…

728 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