Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Adding Minutes to a Time Value.
Tue, Dec 1 2020 11:57 PMPermanent Link

Steve Gill

Avatar

I'm sure I've done this before but I can't seem to find the code anywhere.  

Does anyone know how you increment time by minutes by using a variable instead of an Interval constant?

  DECLARE StartTime TIME;
  DECLARE EndTime TIME;
  DECLARE Duration INTEGER;

  SET Duration = 30;

  SET StartTime = CAST(AppointmentTime AS TIME);
  SET EndTime = CAST(AppointmentTime AS TIME);

--   SET EndTime = StartTime + INTERVAL '60' MINUTE;
  SET EndTime = StartTime + INTERVAL Duration MINUTE;

Thanks.

= Steve
Wed, Dec 2 2020 1:43 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Steve Gill wrote:

> I'm sure I've done this before but I can't seem to find the code
> anywhere.
>
> Does anyone know how you increment time by minutes by using a
> variable instead of an Interval constant?
>
>    DECLARE StartTime TIME;
>    DECLARE EndTime TIME;
>    DECLARE Duration INTEGER;
>
>    SET Duration = 30;
>
>    SET StartTime = CAST(AppointmentTime AS TIME);
>    SET EndTime = CAST(AppointmentTime AS TIME);
>
> --   SET EndTime = StartTime + INTERVAL '60' MINUTE;
>    SET EndTime = StartTime + INTERVAL Duration MINUTE;
>
> Thanks.
>
> = Steve

Hi Steve,

what about defining the Duration as VARCHAR?

DECLARE Duration VARCHAR;
SET Duration='30';


--
--
Yusuf Zorlu | MicrotronX
Wed, Dec 2 2020 4:03 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Steve

>I'm sure I've done this before but I can't seem to find the code anywhere.

AFAIK it has to be a constant - its a question I asked yonks ago and apparently the spec says constant. The only exception seems to be if its a column.

However, since you seem to be doing it in a script it may be possible to fudge it. Nothing comes straight to mind but I'll have a think later.

Roy
Wed, Dec 2 2020 4:46 PMPermanent Link

Steve Gill

Avatar

Hi Yusuf,

<< what about defining the Duration as VARCHAR?

DECLARE Duration VARCHAR;
SET Duration='30'; >>

Thanks,  I tried that but it didn't seem to work.

= Steve
Wed, Dec 2 2020 4:47 PMPermanent Link

Steve Gill

Avatar

Hi Roy,

<< AFAIK it has to be a constant - its a question I asked yonks ago and apparently the spec says constant. The only exception seems to be if its a column.

However, since you seem to be doing it in a script it may be possible to fudge it. Nothing comes straight to mind but I'll have a think later. >>

Yeah I thought as much.  Never mind, I'm going to do it a different way.

Thanks.

= Steve
Image