Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Interval functions
Wed, Oct 24 2007 7:59 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

I had a play with the interval functions (thinking about Harry's post) and found that MONTH and YEAR don't work and the rest all give the same result using the sql below.

select _date,cast((_date - date'2007-01-01') as interval day)
,cast((_date - date'2007-01-01') as interval minute)
,cast((_date - date'2007-01-01') as interval second)
,cast((_date - date'2007-01-01') as interval msecond)
  from transactions

On the basis I know nothing about these weird things it may be dead right.

Roy Lambert

Wed, Oct 24 2007 2:42 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I had a play with the interval functions (thinking about Harry's post)
and found that MONTH and YEAR don't work and the rest all give the same
result using the sql below. >>

a) What does your MONTH and YEAR interval query look like ?

b) You must CAST the result into a string representation, otherwise you will
see the native INTERVAL representation (In64):

select _date,cast(cast((_date - date'2007-01-01') as interval day) as
varchar(20))....

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Oct 25 2007 4:55 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


>a) What does your MONTH and YEAR interval query look like ?

================================================================================
SQL Error (ElevateDB 1.05 Build 2)
================================================================================

ElevateDB Error #700 An error was found in the statement at line 1 and column 28
(Expected Char, VarChar, Byte, VarByte, SmallInt, Integer, BigInt, Interval
Year or Interval Year To Month expression but instead found ("_date" - DATE
'2007-01-01'))


>b) You must CAST the result into a string representation, otherwise you will
>see the native INTERVAL representation (In64):
>
> select _date,cast(cast((_date - date'2007-01-01') as interval day) as
>varchar(20))....

Cor - its all obvious this stuff ain't it Smiley

Roy Lambert
Fri, Oct 26 2007 4:07 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< ElevateDB Error #700 An error was found in the statement at line 1 and
column 28
(Expected Char, VarChar, Byte, VarByte, SmallInt, Integer, BigInt, Interval
Year or Interval Year To Month expression but instead found ("_date" - DATE
'2007-01-01')) >>

Use this instead:

select _date,
(_date - date'2007-01-01') year,
(_date - date'2007-01-01') year to month,
(_date - date'2007-01-01') month,
.......

http://www.elevatesoft.com/edb1sql_arithmetic_operators.htm

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Oct 27 2007 3:41 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


I have a horrible feeling I'm going to have to print the manual out and read it Frown

Roy Lambert
Image