Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Selecting on dates
Mon, Apr 23 2012 9:27 AMPermanent Link

Peter Hodgson

Hi

new to elevateDB from DBISAM

this does not work in EDB

Select * from Planner where  CAST(StartTime as Date)='2010-12-31'

but this does

Select * from Planner where  CAST(StartTime as Date)=cAST('2010-12-31' AS DATE)

Is this right?

Is 'yyyy-mm-dd' right?

Thanks in advance

Peter
Mon, Apr 23 2012 9:30 AMPermanent Link

John Hay

Peter

> Select * from Planner where  CAST(StartTime as Date)=cAST('2010-12-31' AS DATE)
>

Alternatively

Select * from Planner where  CAST(StartTime as Date)= Date '2010-12-31'

John

Mon, Apr 23 2012 10:30 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Peter


As John says - you may also find it useful to read up on INTERVALs if you do any date arithmetic. You can no longer do things like (date1 -  date2) > 90 in SQL

Roy Lambert [Team Elevate]
Mon, Apr 23 2012 10:48 AMPermanent Link

Adam Brett

Orixa Systems

Peter

CAST('2010-12-31' AS DATE)

Still works. You would use it:

WHERE StartDate > CAST('2012-12-31' as DATE)

You can also use:

DATE '2012-12-31'

as another poster mentions.


WHERE StartDate > DATE '2012-12-31'

--

As Roy mentions where you would have written


WHERE StartDate > Current_Date - 90

You now have to write:

WHERE StartDate > Current_Date - INTERVAL '90' DAY

Or you might want to get more or less the same result with:

WHERE StartDate > Current_Date - INTERVAL '3' MONTH

--

I found INTERVALs a pain when starting EDB, and the date handling makes SQL more verbose than with DBISAM. However they do have benefits ... as you can now specify intervals such as working weeks, and whole months much more accurately.

With my SQL Scripts from DBISAM I did a lot of Find and Replace to cope with the changes of querying dates ... and that worked pretty well.
Mon, Apr 23 2012 1:51 PMPermanent Link

Peter Hodgson

Thanks Guys

I'm on a steep learning curve with this!!!!!

Peter
Image