Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - HOWTO: Format date/time values
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HOWTO: Format date/time values

 Post Reply Post Reply
Author
Message
RichardJ View Drop Down
Newbie
Newbie


Joined: 11 April 2011
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote RichardJ Quote  Post ReplyReply Direct Link To This Post Topic: HOWTO: Format date/time values
    Posted: 11 April 2011 at 9:31am

I am adding some date/time values as CXTPReportRecordItemDateTime items and I would like to format the date and time string displayed in the cell.  How do I do this?

Using Column->SetFormatString() with a string such as "dd/MM/yyyy HH:mm:ss" (the value from GetLocaleInfo()) doesn't do the job.


Product: Xtreme Toolkit Pro (MFC) version v15.0
Platform: Windows XP (32bit) - SP 3
Language: VC++ 2010

Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2011 at 3:52pm
Hi;
I do it this way:

   Item=AddItem(new CXTPReportRecordItemDateTime(COleDateTime(Date)));
    Item->SetFormatString("%d.%m.%Y");


I can't find a SetFormatString() function in CXTPReportColumn class?!?!
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
RichardJ View Drop Down
Newbie
Newbie


Joined: 11 April 2011
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote RichardJ Quote  Post ReplyReply Direct Link To This Post Posted: 12 April 2011 at 5:12am

Thanks for the answer.

My mistake, SetFormatString() is on the item not the column.

The documentation for the method is incorrect here.  CXTPReportRecordItem::SetFormatString says to look at the sprintf format specifications whereas for CXTPReportRecordDateTimeItem::SetFormatString I should be looking at the strftime format specifications.  The sprintf format specifications don't actually have any codes for dates or times.

Unfortunately it looks like it's going to be tricky to use the user's/system preferences to do the formatting since this would require translating from one format specification to another.

Back to Top
RichardJ View Drop Down
Newbie
Newbie


Joined: 11 April 2011
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote RichardJ Quote  Post ReplyReply Direct Link To This Post Posted: 12 April 2011 at 5:24am
On further investigation, the formatting code %c respect's the user's settings.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.