Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not a valid time format?
#12
The correct way of doing it is:

Code:
UserSession.FDQryUsersMod.FieldByName('Anddat').AsDateTime := Now;

As Soren mentioned

This is not related to IntraWeb directly. For some reason, your ShortDate format variable is being set to a different format (yyyy-mm-dd instead of dd/mm/yyyy) as you expect.

One thing that you must do if you convert from string to date frequently using FormatDateTime() (or DateTimeToStr()/StrToDate() etc.) is setting the desired format variables when the application starts:

In your OnConfig event, in ServerController, set it as desired:

Code:
procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
begin
  SysUtils.FormatSettings.ShortDateFormat := 'dd/mm/yyyy';
end;

nevertheless, I still recommend you to set the field value using AsDateTime which performs better, doesn't require multiple conversions from/to string and doesn't depend on current format settings
Reply


Messages In This Thread
Not a valid time format? - by Mikael Nilsson - 06-29-2020, 10:44 AM
RE: Not a valid time format? - by Mikael Nilsson - 07-02-2020, 09:24 AM
RE: Not a valid time format? - by Mikael Nilsson - 07-02-2020, 10:11 AM
RE: Not a valid time format? - by SorenJensen - 07-02-2020, 01:43 PM
RE: Not a valid time format? - by Mikael Nilsson - 07-02-2020, 01:59 PM
RE: Not a valid time format? - by SorenJensen - 07-02-2020, 02:08 PM
RE: Not a valid time format? - by SorenJensen - 07-02-2020, 03:31 PM
RE: Not a valid time format? - by Mikael Nilsson - 07-03-2020, 06:57 AM
RE: Not a valid time format? - by Mikael Nilsson - 07-03-2020, 12:35 PM
RE: Not a valid time format? - by Alexandre Machado - 07-04-2020, 02:38 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)