?
Solved

Increment date in IntrBase

Posted on 1997-12-16
2
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
dionysos_swamp earned 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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