🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by Robert G. Hoover Wed, 24 Jan 2007 02:31
TDateTime
#2647
Author: Robert G. Hoover
Date: Wed, 24 Jan 2007 02:31
6 lines
1064 bytes
Is there an easy way to add time to a TDateTime object? I'd like to add an hour
or a minute, etc.

Thanks,

Rob
Re: TDateTime
#2649
Author: Dennis Jones
Date: Wed, 24 Jan 2007 03:10
21 lines
1334 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message 
news:45b6c4c7@newsgroups.borland.com...
> Is there an easy way to add time to a TDateTime object? I'd like to add an 
> hour
> or a minute, etc.
>
> Thanks,
>
> Rob

Here's a simple method:

  TDateTime dt = Now();
  printf( "\n%s", AnsiString(dt).c_str() );  // ex. print 1/23/2007 7:00:00 
PM
  dt += EncodeTime(1, 0, 0, 0);
  printf( "\n%s", AnsiString(dt).c_str() );  // ex. print 1/23/2007 8:00:00 
PM

- Dennis 
Re: TDateTime
#2650
Author: Robert G. Hoover
Date: Wed, 24 Jan 2007 03:23
30 lines
1788 bytes
Awesome! I guess I didn't realize I could just add a number to it!

Thanks!

Rob


Dennis Jones wrote:
> "Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message 
> news:45b6c4c7@newsgroups.borland.com...
>> Is there an easy way to add time to a TDateTime object? I'd like to add an 
>> hour
>> or a minute, etc.
>>
>> Thanks,
>>
>> Rob
> 
> Here's a simple method:
> 
>   TDateTime dt = Now();
>   printf( "\n%s", AnsiString(dt).c_str() );  // ex. print 1/23/2007 7:00:00 
> PM
>   dt += EncodeTime(1, 0, 0, 0);
>   printf( "\n%s", AnsiString(dt).c_str() );  // ex. print 1/23/2007 8:00:00 
> PM
> 
> - Dennis 
> 
> 
Re: TDateTime
#2651
Author: Clayton Arends
Date: Wed, 24 Jan 2007 06:41
6 lines
1004 bytes
Also, check out the IncXXX functions in DateUtils (and the help).

  TDateTime tomorrow = IncDay(Now(), 1);
  TDateTime yesterday = IncDay(Now(), -1);

- Clayton 
Re: TDateTime
#2656
Author: Remy Lebeau (TeamB)
Date: Wed, 24 Jan 2007 18:09
16 lines
1206 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in
message news:45b6c4c7@newsgroups.borland.com...

> Is there an easy way to add time to a TDateTime object? I'd like
> to add an hour or a minute, etc.

If you are using BCB 6 or higher, then the VCL has functions for that:

    IncHour()
    IncMinute()

Look in the DateUtils unit for other Date/Time related functions


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads