SQL query current date retreiving wrong data

Gianni
Gianni used Ask the Experts™
on
Hi,
I want to execute a query on a Sybase ASA database to evaluate the status of a contract.
I'm using current date, but this function is retreiving 2003-02-09 even if today is 24/05/2012.
The date and time of the server is correct, but I retreive this strange currenbt date.
G
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Joe WoodhousePrincipal Consultant
Most Valuable Expert 2012

Commented:
Show us the SQL please?

Author

Commented:
1st query to check CURRENT DATE, it returns 2003-02-19 instead of 2012-05-25

SELECT vencontline.eq_id, vencontline.vencont_id, vn.company, vencontline.date_start, vencontline.date_exp,CURRENT DATE from afm.vencontline join afm.vencont on vencontline.vencont_id=vencont.vencont_id join afm.vn on vencont.vn_id=vn.vn_id  vencontline.eq_id='00650047918'

2nd query that shows that CURRENT DATE returns a value < 2012-01-01

SELECT vencontline.eq_id, vencontline.vencont_id, vn.company, vencontline.date_start, vencontline.date_exp,CURRENT DATE from afm.vencontline join afm.vencont on vencontline.vencont_id=vencont.vencont_id join afm.vn on vencont.vn_id=vn.vn_id where CURRENT DATE < vencontline.date_start and vencontline.eq_id='00650047918'


Regards, Gianni
Query-1-result.JPG
Query-2-result.JPG
Joe WoodhousePrincipal Consultant
Most Valuable Expert 2012

Commented:
Check the date on the box is correct?

Try rewriting 2nd query to replace

     CURRENT DATE < vencontline.date_start

with

     vencontline.date_start > CURRENT DATE

?
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Author

Commented:
Hi,
what did you mean with "check the date on the box?"

If I change the query as suggested, the problem is still there, Current Date returns 2003-02-19 instead of the today date 2012-05-25.
Principal Consultant
Most Valuable Expert 2012
Commented:
Check that the system date as returned by the operating system is correct on the host where this database is running.

Author

Commented:
Oops, date and time incorrect on the server!
Thanks.
Joe WoodhousePrincipal Consultant
Most Valuable Expert 2012

Commented:
:) Always pays to check the obvious things first.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial