Home > Back-end >  How to use Delphi formatdatetime function? The novice consult
How to use Delphi formatdatetime function? The novice consult

Time:09-26

Part of the code:
Testdate>=to_date (: ST, "YYYYMMDD") and testdateParambyname (' ST '). AsString:=formatdatetime (' yyyymmdd 'datetimepicker1. Date)
Parambyname (' FT). The AsString: formatdatetime=(' yyyymmdd 'datetimepicker1. Date + 10/24)

Look at the trouble where is wrong? Don't add 10/24 like is like, plus one can be like?

CodePudding user response:

Have a look at this a few function
IncDay Returns a date shifted by a specified number of days.
IncHour Returns a date/time value shifted by a specified number of hours.
IncMilliSecond Returns a date/time value shifted by a specified number of milliseconds.
IncMinute Returns a date/time value shifted by a specified number of minutes.
IncSecond Returns a date/time value shifted by a specified number of seconds.
IncWeek Returns a date shifted by a specified number of weekes.
IncYear Returns a date shifted by a specified number of years.

To Uses DateUtils

CodePudding user response:

TDatetime is actually a double type, should be can add 10/24, 10/24 is said don't know what you're here

CodePudding user response:

refer to the second floor cocokuaqsw response:
TDatetime is actually a double type, should be can add 10/24, don't know what you are here 10/24 said
representative datetimepicker1 * 10 + 1/24, it is strange that all not line, can add 1 days, plus 10 hours?

CodePudding user response:

1, TDatetime is actually type double, can add 10/24,
2, + 10/24 is extended for 10 hours,
3, although you extended for 10 hours, but if can't go to 1, formatdatetime (' yyyymmdd 'datetimepicker1. Date + 10/24) value or worth,

Suggest you use: formatdatetime (' yyyymmdd hh, datetimepicker1 Date + 10/24), character display (add) hours, see if you joined in 10/24,

CodePudding user response:

In addition, if you calculate number of days and hours, 1 day, you can use the code implementation:

Formatdatetime (' yyyymmdd hh, Round (datetimepicker1. Date + 10/24));

CodePudding user response:

Formatdatetime (' yyyymmdd 'Round (datetimepicker1. Date + 10/24));

CodePudding user response:

Suggest using DateUtils in function, a lot of very full
  • Related