Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: DateTime


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 11 - Last Post: Feb 22, 2018 2:26 AM Last Post By: Kim Madsen Threads: [ Previous | Next ]
Melissa Torn

Posts: 143
Registered: 4/30/09
DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2018 11:41 PM
I need to check if the time is greater than 09:00
how can i do it ? something like below
If Now >= 09:00:00

Thank You
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 1:22 AM   in response to: Melissa Torn in response to: Melissa Torn
trunk(Now)>=encodetime(9,0,0)

best regards
Kim/C4D

On 20/02/2018 08.41, Melissa Torn wrote:
I need to check if the time is greater than 09:00
how can i do it ? something like below
If Now >= 09:00:00

Thank You
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 1:24 AM   in response to: Melissa Torn in response to: Melissa Torn
Argh... the reverse... :)

frag(now)>=encodetime(9,0,0)

Sorry
best regards
Kim/C4D

On 20/02/2018 08.41, Melissa Torn wrote:

I need to check if the time is greater than 09:00
how can i do it ? something like below
If Now >= 09:00:00

Thank You
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 1:26 AM   in response to: Kim Madsen in response to: Kim Madsen
Ok.. I should stop replying unless Im awake....
Now there is a misspelling...

frac(now)>=encodetime(9,0,0)

grrr...

best regards
Kim/C4D

On 20/02/2018 10.24, Kim Madsen wrote:

Argh... the reverse... :)

frag(now)>=encodetime(9,0,0)

Sorry
best regards
Kim/C4D

On 20/02/2018 08.41, Melissa Torn wrote:

I need to check if the time is greater than 09:00
how can i do it ? something like below
If Now >= 09:00:00

Thank You
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 9:00 AM   in response to: Kim Madsen in response to: Kim Madsen
Kim Madsen wrote:

Argh... the reverse... :)

frag(now)>=encodetime(9,0,0)

Sorry

The Now() function returns the current time and date. If you are not
going to use the date portion, don't retrieve it to begin with. Use
the Time() function instead of the Now() function (and if you need a
date without a time portion, use the Date() function).

But, even if you do have a TDateTime that has a date portion, you
should use the TimeOf() function to strip off the date, not use the
Frag() function. The fact that a TDateTime is implemented using a
floating point data type is an implementation detail of the
compiler/RTL. It is never good to rely on implementation details when
there are public interfaces defined to do the same work in an
implementation-independant manner.

--
Remy Lebeau (TeamB)
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 10:36 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Hi,

I somewhat agree with you. But its very unlikely that current TDateTime
will change in format. It has been a double since dawn of days (in
Delphi terms anyway).

Changing it to something incompatible with a double is going to break
alot of software without any good reason. So I fear not that frac or
trunk will be problematic with TDateTime and it may save a couple of cpu
cycles in a tight spot.

best regards
Kim/C4D

On 20/02/2018 18.00, Remy Lebeau (TeamB) wrote:

Kim Madsen wrote:

Argh... the reverse... :)

frag(now)>=encodetime(9,0,0)

Sorry

The Now() function returns the current time and date. If you are not
going to use the date portion, don't retrieve it to begin with. Use
the Time() function instead of the Now() function (and if you need a
date without a time portion, use the Date() function).

But, even if you do have a TDateTime that has a date portion, you
should use the TimeOf() function to strip off the date, not use the
Frag() function. The fact that a TDateTime is implemented using a
floating point data type is an implementation detail of the
compiler/RTL. It is never good to rely on implementation details when
there are public interfaces defined to do the same work in an
implementation-independant manner.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 11:05 AM   in response to: Kim Madsen in response to: Kim Madsen
Kim Madsen wrote:

Hi,

I somewhat agree with you. But its very unlikely that current
TDateTime will change in format. It has been a double since dawn of
days (in Delphi terms anyway).

I understand that. But it is still not a good choice to write code
that acts on the private format directly. The RTL has many functions
for querying and manipulating TDateTime values regardless of the
format. You should use them.

--
Remy Lebeau (TeamB)
Van Swofford

Posts: 397
Registered: 6/28/03
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 12:44 PM   in response to: Kim Madsen in response to: Kim Madsen
Kim Madsen wrote:

Changing it to something incompatible with a double is going to break
alot of software without any good reason.

That never stopped Embarcadero before. :-)

--
Cheers,
Van

"Good judgment comes from experience, and a lot of that comes from bad
judgment." - Will Rogers
Uffe Kousgaard

Posts: 218
Registered: 2/7/00
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 9:49 PM   in response to: Kim Madsen in response to: Kim Madsen
Kim Madsen wrote:

Changing it to something incompatible with a double is going to break
alot of software without any good reason. So I fear not that frac or
trunk will be problematic with TDateTime and it may save a couple of
cpu cycles in a tight spot.

Trunc
Not trunk
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 22, 2018 2:26 AM   in response to: Uffe Kousgaard in response to: Uffe Kousgaard
On 22/02/2018 06.49, Uffe Kousgaard wrote:
Kim Madsen wrote:

Changing it to something incompatible with a double is going to break
alot of software without any good reason. So I fear not that frac or
trunk will be problematic with TDateTime and it may save a couple of
cpu cycles in a tight spot.

Trunc
Not trunk

Yeh... my spelling is significantly off in my replies in this thread :)

Trunk probably influenced by my daily use of Subversion, and frag by my
influence by Battlefield 1 :)

best regards
Kim/C4D
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 8:55 AM   in response to: Melissa Torn in response to: Melissa Torn
Melissa Torn wrote:

I need to check if the time is greater than 09:00
how can i do it ? something like below
If Now >= 09:00:00

If Time >= EncodeTime(9, 0, 0, 0) then


--
Remy Lebeau (TeamB)
Melissa Torn

Posts: 143
Registered: 4/30/09
Re: DateTime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 11:08 AM   in response to: Melissa Torn in response to: Melissa Torn
Thank You Kim, Remy
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02