Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Show date as mm/dd/yy in Data Grid
Sun, Jul 14 2019 11:40 PMPermanent Link

KimHJ

Comca Systems, Inc

Is it possible to change the date column in a grid to show the date as MM/dd/yy instead of showing it like it is stored in the database yyyy-MM-dd?

The grid is connected to a Date Column in a EDB dataset.

I tried to check Localize in the dataset, but no luck.

Thanks,
Kim
Wed, Jul 17 2019 8:38 AMPermanent Link

Uli Becker

> Is it possible to change the date column in a grid to show the date as MM/dd/yy instead of showing it like it is stored in the database yyyy-MM-dd?

Did you use the format settings? If not put it in the initialization section of your main form like this (German format settings in this case):

initialization

   FormatSettings.Translations.Values['DLG_BTN_CANCEL']:='Abbrechen';
   FormatSettings.Translations.Values['DLG_BTN_YES']:='Ja';
   FormatSettings.Translations.Values['DLG_BTN_NO']:='Nein';
   FormatSettings.DecimalSeparator := ',';

   FormatSettings.DateSeparator:= '.';
   FormatSettings.ShortdateFormat := 'dd.MM.yyyy';
   FormatSettings.ShortTimeFormat := 'HH:mm';

   FormatSettings.LongDayNames[1] := 'Montag';
   FormatSettings.LongDayNames[2] := 'Dienstag';
   FormatSettings.LongDayNames[3] := 'Mittwoch';
   FormatSettings.LongDayNames[4] := 'Donnerstag';
   FormatSettings.LongDayNames[5] := 'Freitag';
   FormatSettings.LongDayNames[6] := 'Samstag';
   FormatSettings.LongDayNames[7] := 'Sonntag';
   
   FormatSettings.ShortDayNames[1] := 'Mo';
   FormatSettings.ShortDayNames[2] := 'Di';
   FormatSettings.ShortDayNames[3] := 'Mi';
   FormatSettings.ShortDayNames[4] := 'Do';
   FormatSettings.ShortDayNames[5] := 'Fr';
   FormatSettings.ShortDayNames[6] := 'Sa';
   FormatSettings.ShortDayNames[7] := 'So';
   
   FormatSettings.LongMonthNames[1] := 'Januar';
   FormatSettings.LongMonthNames[2] := 'Februar';
   FormatSettings.LongMonthNames[3] := 'März';
   FormatSettings.LongMonthNames[4] := 'April';
   FormatSettings.LongMonthNames[5] := 'Mai';
   FormatSettings.LongMonthNames[6] := 'Juni';
   FormatSettings.LongMonthNames[7] := 'Juli';
   FormatSettings.LongMonthNames[8] := 'August';
   FormatSettings.LongMonthNames[9] := 'September';
   FormatSettings.LongMonthNames[10] := 'Oktober';
   FormatSettings.LongMonthNames[11] := 'November';
   FormatSettings.LongMonthNames[12] := 'Dezember';

end.

Uli
Wed, Jul 17 2019 11:28 PMPermanent Link

KimHJ

Comca Systems, Inc

Uli Becker wrote:

>>Did you use the format settings? If not put it in the initialization section of your main form like this (German format settings in this case):

initialization

   FormatSettings.Translations.Values['DLG_BTN_CANCEL']:='Abbrechen';
   FormatSettings.Translations.Values['DLG_BTN_YES']:='Ja';
   FormatSettings.Translations.Values['DLG_BTN_NO']:='Nein';
   FormatSettings.DecimalSeparator := ',';

   FormatSettings.DateSeparator:= '.';
   FormatSettings.ShortdateFormat := 'dd.MM.yyyy';
   FormatSettings.ShortTimeFormat := 'HH:mm';

   FormatSettings.LongDayNames[1] := 'Montag';
   FormatSettings.LongDayNames[2] := 'Dienstag';
   FormatSettings.LongDayNames[3] := 'Mittwoch';
   FormatSettings.LongDayNames[4] := 'Donnerstag';
   FormatSettings.LongDayNames[5] := 'Freitag';
   FormatSettings.LongDayNames[6] := 'Samstag';
   FormatSettings.LongDayNames[7] := 'Sonntag';
   
   FormatSettings.ShortDayNames[1] := 'Mo';
   FormatSettings.ShortDayNames[2] := 'Di';
   FormatSettings.ShortDayNames[3] := 'Mi';
   FormatSettings.ShortDayNames[4] := 'Do';
   FormatSettings.ShortDayNames[5] := 'Fr';
   FormatSettings.ShortDayNames[6] := 'Sa';
   FormatSettings.ShortDayNames[7] := 'So';
   
   FormatSettings.LongMonthNames[1] := 'Januar';
   FormatSettings.LongMonthNames[2] := 'Februar';
   FormatSettings.LongMonthNames[3] := 'März';
   FormatSettings.LongMonthNames[4] := 'April';
   FormatSettings.LongMonthNames[5] := 'Mai';
   FormatSettings.LongMonthNames[6] := 'Juni';
   FormatSettings.LongMonthNames[7] := 'Juli';
   FormatSettings.LongMonthNames[8] := 'August';
   FormatSettings.LongMonthNames[9] := 'September';
   FormatSettings.LongMonthNames[10] := 'Oktober';
   FormatSettings.LongMonthNames[11] := 'November';
   FormatSettings.LongMonthNames[12] := 'Dezember';

end. <<

Thanks, for opening my eyes. I have serval other programs made with EWB and all of the have the date showing right. The different in this application is, I use the FormatSettings to format the date to get the data for the Grid.

   FormatSettings.ShortDateFormat := 'yyyy MM dd';
   FormatSettings.DateSeparator := '-';
   FindClock.Params.Clear;
   FindClock.Params.Add('ClockDate>=' + QuotedStr(DateToStr(FromDate)))

I was not aware that that would change the way it was displayed in the Grid.
I added the new FormatSettings in AfterLoad of the DataSet and now it display just as it should.

Thanks,
Kim
Image