[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Increment date in IntrBase

Posted on 1997-12-16
2
Medium Priority
?
257 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

Technology Partners: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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