Subject | Re: [ib-support] Re: working with date/time |
---|---|
Author | Paul Schmidt |
Post date | 2002-01-14T23:46:30Z |
On 14 Jan 2002, at 16:34, csswa wrote:
IBO is very developer friendly, unfortunately my platform of choice,
consists of C++, and I didn't like C++ Builder.
Dialect 1 for platform reasons, then there are a couple of tricks.
First is that a timestamp is usually stored as a double usually in
days. So try this (it's theoretical I have not tested this) cast the
timestamp to a double ( this should give you a real number
something like 65983.25 -- the 65983 is the number of days since
the epoch (a given date in time represented as day 0, Jan 1, 1900
is common, January 1, 1970 is I think the date used in Unix ). You
don't really care about the date part you want the fraction.
So take the .25 from above, multiple by 1440 this will give you a
minute number divide by 60 for the hours, modulus by 60 to get the
minutes. If you need seconds, then if there is a fractional part after
the minutes multiply it by 60.
This will give you hours and minutes, or hours, minutes and
seconds, you can play with in your code.
If you need this on the server side, then you will need to construct
a UDF to extricate the parts. I don't think the 4 function math in
SQL is sufficient for it.
Often it's easier to play with it, on the client side, extract the
timestamp into a Delphi date/time variable and use the parts
individually.
Paul
Paul Schmidt
Tricat Technologies
paul@...
www.tricattechnologies.com
> Thanks for the feedback, Helen and Paul. IBO just seems a bit steepI haven't used FIBPlus, I only used IBO with Delphi, I will say the
> when compared to FIBplus at half the price... this is where I need
> some unbiased advice comparing the two. Is FIBplus considered IBO's
> poor cousin? Does it offer only half the useability of IBO? Does
> anyone have any gripes against either? I don't mean to devalue either
> product, nor do I wish to start a 'mine is better than yours' debate.
> I'm just trying to be a smart shopper. I'm also curious about why the
> big price difference in what seems to be two very similar products,
> both offering a solid history and comprehensive features.
>
> If the consensus is that IBO is the only way to go, I will indeed
> shell out my $740 AUD tax deduction and consider it well spent. I
> must admit, I do like to walk away with a 'steal', which is why I'm
> eyeing off FIBplus. So if it's fair to say that FIB+ and IBO both get
> the job done and both have their pros and cons, then I'd probably go
> for FIB+ I suppose... Heck, if if it wasn't for dialect 3 I might
> just stick with the original FreeIB stuff which still works great.
IBO is very developer friendly, unfortunately my platform of choice,
consists of C++, and I didn't like C++ Builder.
> Also, I have yet to discover how to create a TIME field from aDialect 3, is probably the best way to go, however if you are tied to
> TIMESTAMP in dialect 1, e.g. a computed field that shows TIME part of
> another TIMESTAMP field. Can it be done with CASTing? Is it done via
> UDF? How have people been dealing with time fields prior to dialect
> 3? With CHAR fields and manually chunking out substrings? Judging
> from the earlier lack of response to this question, either I'm missing
> the obvious solution or the solution is too complex to bother with???
> Let me guess: just use dialect 3...
Dialect 1 for platform reasons, then there are a couple of tricks.
First is that a timestamp is usually stored as a double usually in
days. So try this (it's theoretical I have not tested this) cast the
timestamp to a double ( this should give you a real number
something like 65983.25 -- the 65983 is the number of days since
the epoch (a given date in time represented as day 0, Jan 1, 1900
is common, January 1, 1970 is I think the date used in Unix ). You
don't really care about the date part you want the fraction.
So take the .25 from above, multiple by 1440 this will give you a
minute number divide by 60 for the hours, modulus by 60 to get the
minutes. If you need seconds, then if there is a fractional part after
the minutes multiply it by 60.
This will give you hours and minutes, or hours, minutes and
seconds, you can play with in your code.
If you need this on the server side, then you will need to construct
a UDF to extricate the parts. I don't think the 4 function math in
SQL is sufficient for it.
Often it's easier to play with it, on the client side, extract the
timestamp into a Delphi date/time variable and use the parts
individually.
Paul
Paul Schmidt
Tricat Technologies
paul@...
www.tricattechnologies.com