While debuggin, I ran into two variables: one had a date of 38675 and a time
portion of 0.9999999: debugging this will result in a datetiometostr() into a
datetotime 0.00.00 and the var itself (within the debugger) did show 38676 ==
the next date!.
The other var had a time portion of 0.1 and was therfore for sure the next day.
For me the formatdatetime did the correct comparison. If this, as you say, is a
correct way of doing it, i will use this.
thanks for all suggestion
Andries
David Smith <[EMAIL PROTECTED]> wrote:
I thought you wanted to see if they were the same
day? The day is represented by the > 0 part of
TDatetime. Just like if you wanted to check if times
are equal, you'd use
If frac(A) = frac(B) then // times are equal
When comparing times this way, they have to be
equal down to the millisecond. You can use
formatDatetime to reduce the accuracy of the reported
time if you want it to the nearest time increment
(like 1 minute, 5 mins. etc.). A solution to that was
recently posted (your post in fact I think).
This is the standard way it's done and I've never
had a problem with it in my Calendar/Scheduler
application.
DJS
--- Andries Bos <[EMAIL PROTECTED]> wrote:
> Hello
>
> formatdatetime did the job and gave to right
> opportunity, although it's a quite unsatisfying
> solution;
>
> Trunc(A) = trucn (B) will not succeed as the
> timeof(A) part deliveres 0,09999 and therefor
> trunc(A) deliveres a result of ( dateof(A) -1 )
>
> regards
>
> Andries
>
> David Smith <[EMAIL PROTECTED]> wrote:
> Even simpler:
>
> If trunc(A) = trunc(B) Then //dateTimes are same
> day
>
> DJS
>
>
> --- Software Developer <[EMAIL PROTECTED]> wrote:
>
> >
>
>
result:=formatdatetime('dd.mm.yy',a)=formatdatetime('dd.mm.yy',b);
> >
> >
> > --- Software Developer <[EMAIL PROTECTED]> wrote:
> >
> > > Hello
> > >
> > > try this :
> > >
> > > function SameDay(a,b:DateTime):Boolean;
> > > begin
> > >
> > >
> >
>
>
result:=formatdatetime('dd.mm.yy',a)=formatdatetime('dd.mm.yy',a);
> > > end;
> > >
> > >
> > > Regards
> > > Baran
> > > --- Andries Bos <[EMAIL PROTECTED]> wrote:
> > >
> > > > Hello
> > > >
> > > > I do have two TDateTime values to compare.
> > > >
> > > > var
> > > > A: TDateTime;
> > > > B : TDateTime;
> > > >
> > > > Debugging gives me a value for the variable
> of A
> > =
> > > > 38676 and B = 38676,1. Using the delhi
> debugging
> > > > function will show the values
> > > > A : (DateTimeToStr(A) : '20-11-2005' and
> > > > B : (DateTimeToStr(B) '20-11-2005
> 2:24:00'
> > > >
> > > > I would like to compare these two dates and
> > check
> > > if
> > > > they are equal (on the same day). Dayofweek
> > would
> > > > not help because these dates could b within
> > > > different weeks
> > > >
> > > > However checking using the integrated
> debigger
> > var
> > > A
> > > > with either of the functions : DateOf(A)
> > Trunc(A)
> > > > or Int(A) will all result in a value of
> 38675
> > !!.
> > > > Doing the same with B will succeed en give
> me
> > the
> > > > value I would expect (38676). (As I'm doing
> > > > something conditional , the debugging values
> > will
> > > > also show at a normal run).
> > > > I've tried to store the outcome of the
> functions
> > > > into a local variable, but this also does
> not
> > > solve
> > > > my problem.
> > > >
> > > > Any suggestions?
> > > >
> > > > regards
> > > >
> > > > Andries
> > > > The Netherlands
> > > >
> > > >
> > > >
> > > > ---------------------------------
> > > > Yahoo! Shopping
> > > > Find Great Deals on Holiday Gifts at Yahoo!
> > > > Shopping
> > > >
> > > > [Non-text portions of this message have been
> > > > removed]
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! for Good - Make a difference this year.
>
> > > http://brand.yahoo.com/cybergivingweek2005/
> > >
> >
> >
> >
> >
> >
> > __________________________________
> > Yahoo! for Good - Make a difference this year.
> > http://brand.yahoo.com/cybergivingweek2005/
> >
>
>
>
>
>
> __________________________________
> Yahoo! for Good - Make a difference this year.
> http://brand.yahoo.com/cybergivingweek2005/
>
>
>
>
-----------------------------------------------------
> Home page:
> http://groups.yahoo.com/group/delphi-en/
> To unsubscribe:
> [EMAIL PROTECTED]
>
>
>
> ---------------------------------
> YAHOO! GROUPS LINKS
>
>
> Visit your group "delphi-en" on the web.
>
> To unsubscribe from this group, send an email
> to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the
> Yahoo! Terms of Service.
>
>
> ---------------------------------
>
>
>
>
>
>
> ---------------------------------
> Yahoo! for Good - Make a difference this year.
>
> [Non-text portions of this message have been
> removed]
>
>
__________________________________________
Yahoo! DSL � Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "delphi-en" on the web.
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays,
whatever.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
AIDS in India: A "lurking bomb." Click and help stop AIDS now.
http://us.click.yahoo.com/9QUssC/lzNLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~->
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/