Solved

Increment date in IntrBase

Posted on 1997-12-16
2
252 Views
Last Modified: 2010-04-04
One of my fields is a date field in IntrBase. I will increment each new record the date with one day. In which way can i do that?
And is it possible to show the record with the date of today? I have days in the past and the future, but i want to open with the date of today.
0
Comment
Question by:scones
2 Comments
 
LVL 1

Accepted Solution

by:
dionysos_swamp earned 100 total points
ID: 1354003
>I will increment each new record the date with one day.
>In which way can i do that?

well, get the last date in the database like so:
  select max(DateThingy) from TableThingy
that should do the trick.

put that date into a variable like so:
  curdate := query1.fieldbyname('max').asDateTime
or some thing like that...

then have your loop:
while there_are_more_tuples_to_insert do begin
  curdate := curdate +1; //1 = one day in Tdatetime
  insert into TableThingy (dateThingy,other,fields,that,are,fun)
  values ('+timedatetostr(curdate)+',1,2,3,4,5)
end;

I'm not sure about the call to timedatetostr, it may need some strange parameter.

>And is it possible to show the record with the date of today?
well, uhm:

 with query1 do begin
  today := '10 dec 1997'
  sql.clear;
  sql.add('select * from tableThingy');
  sql.add('where dateThingy >= '+today+' "00:00:00"');
  sql.add('  and dateThingy <= '+today+' "24:59:59"');
  open;
  for c := 0 to recordCount-1 do begin

   do your thing here using: fieldbyname('cheese');

   next;
  end;
  close;
 end;

Bonus tip: when creating the database you may also like to do this:

create table tableThingy(
  ...
  dateThingy date default now,
  ...);
using default will let you insert into the database without worrying about the date if you just want it to be today as it is inserted automaticly in stead of null.

Hope this helps

0
 

Author Comment

by:scones
ID: 1354004
Thanks for the info. I am try it immediately.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question