Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 6 of 6 total |
Add months to date using SQL |
Wed, Mar 1 2006 8:44 PM | Permanent Link |
"Halim Boumedjirek" | How can I add a certain number of months to a timesatmp field and use it
inside my query : select * from mytable where mytable.BusinessDate + 28 months <"2006-06-01" thanks, -Halim |
Wed, Mar 1 2006 9:34 PM | Permanent Link |
Jeff Cook | "Halim Boumedjirek" <Hboumedjirek@idealss.com> wrote on Wed, 1 Mar 2006 19:43:32 -0600
>How can I add a certain number of months to a timesatmp field and use it >inside my query : >select * from mytable where mytable.BusinessDate + 28 months <"2006-06-01" > >thanks, >-Halim > > Halim I don't know if you can, but why not subtract the months from the date on the right of the < instead - presumably you had to make this date in code anyway. Something like:- YourDate := ..... ; YourMonths := ....; with Query1 do begin SQL.Text := 'select * from mytable where mytable.BusinessDate< :TestDate'; ParamByName('TestDate').AsDateTime := IncMonth(YourDate, -YourMonths); Open; end; HTH Cheers Jeff -- Jeff Cook Aspect Systems Ltd Phone: +64-9-424 5388 Skype: jeffcooknz www.aspect.co.nz |
Thu, Mar 2 2006 9:26 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Halim,
<< How can I add a certain number of months to a timesatmp field and use it inside my query : select * from mytable where mytable.BusinessDate + 28 months <"2006-06-01" >> Do you simply want to increment the month portion of the date by 28 ? Or do you want to add approximately (30*28) days ? -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Mar 2 2006 1:22 PM | Permanent Link |
"Halim Boumedjirek" | Yes, I want to increment the month portion by 28 months.
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message news:20DBB8F7-B584-4A6C-84B0-C2FCFA43A5CA@news.elevatesoft.com... > Halim, > > << How can I add a certain number of months to a timesatmp field and use > it inside my query : select * from mytable where mytable.BusinessDate + > 28 months <"2006-06-01" >> > > Do you simply want to increment the month portion of the date by 28 ? Or > do you want to add approximately (30*28) days ? > > -- > Tim Young > Elevate Software > www.elevatesoft.com > > |
Fri, Mar 3 2006 10:12 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Halim,
<< Yes, I want to increment the month portion by 28 months. >> Sorry about that, I didn't realize that you were incrementing the months by more than a year. You're going to have to To do so, I would recommend using a parameter or a constant like this: select * from mytable where mytable.BusinessDate < :DateParam where the :DateParam is populated with the desired date - 28 months. Or you could just use a constant that you put directly into the SQL text. -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Mar 3 2006 12:39 PM | Permanent Link |
"Halim Boumedjirek" | I went ahead and used IncMonth function. I used it as a constant in the SQL
script. Thanks to all, -Halim "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message news:5AB80C56-595F-4C2B-B250-ABA68BADB206@news.elevatesoft.com... > Halim, > > << Yes, I want to increment the month portion by 28 months. >> > > Sorry about that, I didn't realize that you were incrementing the months > by more than a year. You're going to have to To do so, I would recommend > using a parameter or a constant like this: > > select * > from mytable > where mytable.BusinessDate < :DateParam > > where the :DateParam is populated with the desired date - 28 months. Or > you could just use a constant that you put directly into the SQL text. > > -- > Tim Young > Elevate Software > www.elevatesoft.com > > |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |