Board index » delphi » Converting aa 12-hour to a 24-hour DateTime Format

Converting aa 12-hour to a 24-hour DateTime Format

When I view a table from containing DateTime columns in my SQL
Explorer, datetime values look like this:      4/17/2001 4:23:54 PM or
4/17/2001 4:23:54 AM.

My code to get that date where I used inorder to write to a text file is
similar to this:

  fprintf(fp,"\"%s\"",WorkQuery->Fields->Fields[i]->AsString.c_str( ));

Program successfully captures the datetime format in that manner as
displayed in my SQL Explorer. But how do I work it out in my C++ Builder
code to get that DateTime value in a 24-hour format, thereby removing the
AM/PM designations? Is there a way by which my fprintf statement can be
transformed to convert the 12-hour format of date into a 24-hour format?

Please help.

Thanks in advance.

Sincerely,
JEchavez

 

Re:Converting aa 12-hour to a 24-hour DateTime Format


Quote
"JEchavez" <jecha...@idsfinance.com> wrote in message

news:3c5e46f6_2@dnews...

Quote
> When I view a table from containing DateTime columns in my SQL
> Explorer, datetime values look like this:      4/17/2001 4:23:54 PM or
> 4/17/2001 4:23:54 AM.

> My code to get that date where I used inorder to write to a text file is
> similar to this:

>   fprintf(fp,"\"%s\"",WorkQuery->Fields->Fields[i]->AsString.c_str( ));

This is a typical BCB or Delphi question, not an IB question. Anyway:

You have the field with the binary date and time. You can format it yourself
by hand. You can change some global variables that will override ONLY in
your program the date and time representation. At least I can do that in
Delphi.
But if you want it only for output and not for output, format it yourself or
use one of the date-time formatting routines in the C standard libraries.
There's strftime() for example, but it uses the struct tm, not a Delphi's
timestamp (a double at least in old Delphi versions).

C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase? WebRing

Other Threads