Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 8 of 8 total |
Adding a variable Number of Days to a Date |
Thu, Apr 15 2010 7:47 AM | Permanent Link |
Richard Harding Wise Nutrition Coaching | I can add 1 day to a DATE column by
SET NewScheduledStart = ParentScheduledStart + INTERVAL '1' DAY; Can someone tell me how to add a variable number of days ( say DaysAfter )? SET NewScheduledStart = ParentScheduledStart + ??????????? ; Richard Harding |
Thu, Apr 15 2010 8:04 AM | Permanent Link |
Uli Becker | Richard,
> Can someone tell me how to add a variable number of days ( say DaysAfter )? > > SET NewScheduledStart = ParentScheduledStart + ??????????? ; Obviously parameters are not allowed with intervals, but you can use this: 'SET NewScheduledStart = ParentScheduledStart + interval ' + QUOTEDSTR(IntToStr(DaysAfter)) + ' day ' Uli |
Thu, Apr 15 2010 8:51 AM | Permanent Link |
Richard Harding Wise Nutrition Coaching | Thanks Uli,
What I am trying to do this using cursors -- something like this. WHILE NOT EOF(TempCursor2) DO SET NewScheduledStart = ParentScheduledStart + INTERVAL DaysAfterParent DAY; -- ????????????????????? UPDATE TempCursor2 SET ScheduledStartDate = NewScheduledStart; FETCH NEXT FROM TempCursor2 (DaysAfterParent) INTO DaysAfterParent; END WHILE; May be it is not possible using cursors and I need to do as you suggest --- EXECUTE IMMEDIATE ' UPDATE Activity SET ScheduledStartDate = ParentScheduledStart + interval ' + QUOTEDSTR(IntToStr(DaysAfter)) + ' day ' Richard Harding |
Thu, Apr 15 2010 9:51 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Richard,
<< What I am trying to do this using cursors -- something like this. >> How is DaysAfterParent declared ? Is it an INTEGER or actually declared as an INTERVAL ? I have the same question for the DaysAfterParent column that you're selecting from a table. After I know the above, I can show you how to do it with a cursor. -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Apr 15 2010 4:32 PM | Permanent Link |
Richard Harding Wise Nutrition Coaching | Tim,
<< How is DaysAfterParent declared ? Is it an INTEGER or actually declared as an INTERVAL ? I have the same question for the DaysAfterParent column that you're selecting from a table.>> The DaysAfterParent column is declared as an INTEGER. In the PROCEDURE, DaysAfterParent is also declared as an INTEGER ( this can be changed if required). -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Apr 16 2010 4:28 AM | Permanent Link |
John Hay | Richard
> The DaysAfterParent column is declared as an INTEGER. > In the PROCEDURE, DaysAfterParent is also declared as an INTEGER ( this can be changed if required). > I would guess the following should do it. SET NewScheduledStart = ParentScheduledStart +CAST(DaysAfterParent AS INTERVAL DAY); John |
Sat, Apr 17 2010 6:30 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Richard,
<< The DaysAfterParent column is declared as an INTEGER. In the PROCEDURE, DaysAfterParent is also declared as an INTEGER ( this can be changed if required). >> John's answer is correct. -- Tim Young Elevate Software www.elevatesoft.com |
Sun, Apr 18 2010 4:20 PM | Permanent Link |
Richard Harding Wise Nutrition Coaching | John - Thank you.
<<SET NewScheduledStart = ParentScheduledStart +CAST(DaysAfterParent AS INTERVAL DAY);>> I finally understand how INTERVALS work. Richard Harding. |
This web page was last updated on Saturday, May 4, 2024 at 12:54 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |