Jump to content
erva

TStringGrig formatting date

Recommended Posts

Trying to format date to show dd.mm.yyyy but don't get how it's complished. Have tried it with columns "customFormat" property but with no success.

Share this post


Link to post

Are you using Format? You should be using FormatDateTime.
FormatDateTime('dd.mm.yyyy', Now); should yield '11.05.2020'

Share this post


Link to post

I'am using FormatDateTime('dd.mm.yyyy', %s) and get error "Invalid class typecast".

Share this post


Link to post

Tried FormatDateTime('dd.mm.yyyy', Now); but get this exception:

 

image.thumb.png.81641a9cae5fd3d4d1bb21a936482fb5.png

Share this post


Link to post
1 hour ago, erva said:

I'am using FormatDateTime('dd.mm.yyyy', %s) and get error "Invalid class typecast".

%s is yet a string so it's somewhere normal

Try FormatDateTime('dd.mm.yyyy',value)

or declare your fields, set your date field  displayformat property to 'dd.mm.yyyy' and use displaytext in customformat

  • Thanks 1

Share this post


Link to post
3 hours ago, erva said:

Trying to format date to show dd.mm.yyyy but don't get how it's complished. Have tried it with columns "customFormat" property but with no success.

Hi,

 

  TFormatSettings.Create;
  FormatSettings.ShortDateFormat := 'dd.MM.yyyy'; //
  FormatSettings.LongDateFormat := 'dd.MM.yyyy'; //
  FormatSettings.DateSeparator := '.';
  FormatSettings.ShortTimeFormat := 'hh:mm:ss'; //
  FormatSettings.LongTimeFormat := 'hh:mm:ss'; //

 

regards,

M

Share this post


Link to post

That 'displaytext' property i was missing from grid side, thanks a lot:)

Edited by erva

Share this post


Link to post

Mysterious things happening....

 

I got date formatting working ok. But then made changes to DB structure and after that grids first and last dates show like they should, others not

 

image.png.1b716d877bbd66fd8b659c8bbf516844.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×