Solved

Increment date in IntrBase

Posted on 1997-12-16
2
247 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi OLE Error 8 93
Internet Explorer View Settings Question 15 105
error 1.1 400 Bad request idhttp delphi 18 52
JAudiorecorder record freezing the app 29 59
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

937 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

10 Experts available now in Live!

Get 1:1 Help Now