Solved

Increment date in IntrBase

Posted on 1997-12-16
2
242 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
Comment Utility
>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
Comment Utility
Thanks for the info. I am try it immediately.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now