Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.fds-net.ru/showflat.php?Number=5425199&src=arc&showlite=
Дата изменения: Unknown
Дата индексирования: Wed Apr 13 05:35:43 2016
Кодировка: Windows-1251
[Delphi] Как получить разность дат в виде "дней-часов-минут-секунд"? - Public forum of MSU united student networks
Root | Google | Yandex | Mail.ru | Kommersant | Afisha | LAN Support
  
Technical >> Development (Archive)

Страницы: 1
Basilio
GreenOne

Рег.: 14.10.2002
Сообщений: 13750
Из: Москва
Рейтинг: 3476
  [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд"?
      23.11.2006 15:02
 

типа есть LastEvent :TDateTime
хочу напечатать: 'Со времени последнего события прошло: 23 дня 14:52:05'
значение это вычисляется как (Now-LastEvent)

можно ли стандартными средствами? основная проблема - получить количество "ДНЕЙ" из DateTime

нет, я конечно понимаю, что можно воспользоваться Trunc(Now-LastEvent), но это как-то неэтично чтоли
// короче так и сделал. тему закрываем



Редактировал Basilio (23.11.2006 16:32)
aset
boar

Рег.: 05.09.2003
Сообщений: 36470
Рейтинг: 6913
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд"? [re: Basilio]
      23.11.2006 15:05
 

Неужели в дельфи нет соответствующего компонента?



may have come in contact with nuts
Basilio
GreenOne

Рег.: 14.10.2002
Сообщений: 13750
Из: Москва
Рейтинг: 3476
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: aset]
      23.11.2006 15:06
 

см. упдейт

aset
boar

Рег.: 05.09.2003
Сообщений: 36470
Рейтинг: 6913
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: Basilio]
      23.11.2006 15:06
 

Используй TFileTime



may have come in contact with nuts
Basilio
GreenOne

Рег.: 14.10.2002
Сообщений: 13750
Из: Москва
Рейтинг: 3476
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: aset]
      23.11.2006 15:07
 

ы?!

Adoon
member

Рег.: 03.11.2002
Сообщений: 149
Рейтинг: 101
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: Basilio]
      24.11.2006 12:55
 

Вот все основные ф-ции по работе с датами в Delphi

CheckSqlTimeStamp procedure
Checks whether a TSQLTimeStamp value represents a valid date and time.

CompareDate function
Indicates the relationship between the date portions of two TDateTime values.

CompareDateTime function
Indicates the relationship between two TDateTime values.

CompareTime function
Indicates the relationship between the time portions of two TDateTime values.

CurrentYear function
Returns the current year.

Date function
Returns the current date.

DateDelta constant
Specifies the difference between TDateTime and TTimeStamp values.

DateOf function
Strips the time portion from a TDateTime value.

DateTimeToFileDate function
Converts a TDateTime object to an OS timestamp.

DateTimeToSQLTimeStamp function
Converts a TDateTime value to a TSQLTimeStamp value.

DateTimeToStr function
Converts a TDateTime value to a string.

DateTimeToString procedure
Converts a TDateTime value to a string using a specified Format.

DateTimeToSystemTime procedure
Converts a TDateTime value into the Win32 API's system time type.

DateTimeToTimeStamp function
Converts a TDateTime value into the corresponding TTimeStamp value.

DateToStr function
Converts a TDateTime value to a string.

Day of week constants
Provide symbolic constants for ISO 8601-compliant day of the week values.

DayOf function
Returns the day of the month represented by a TDateTime value.

DayOfTheMonth function
Returns the day of the month represented by a TDateTime value.

DayOfTheWeek function
Returns the day of the week represented by a TDateTime value.

DayOfTheYear function
Returns the number of days between a specified TDateTime value and December 31 of the previous year.

DayOfWeek function
Returns the day of the week for a specified date.

DaysBetween function
Returns the number of whole days between two specified TDateTime values.

DaysInAMonth function
Returns the number of days in a specified month of a specified year.

DaysInAYear function
Returns the number of days in a specified year.

DaysInMonth function
Returns the number of days in the month of a specified TDateTime value.

DaysInYear function
Returns the number of days in the year of a specified TDateTime value.

DaySpan function
Returns the number of days (including fractional days) between two specified TDateTime values.

DecodeDate procedure
Returns Year, Month, and Day values for a TDateTime value.

DecodeDateDay procedure
Returns the year and day of the year for a specified TDateTime.

DecodeDateFully function
Returns Year, Month, and Day, and Day-of-Week values for a TDateTime value.

DecodeDateMonthWeek procedure
Returns the year, month, week of the month, and day of the week for a specified TDateTime.

DecodeDateTime procedure
Returns Year, Month, Day, Hour, Minute, Second, and Millisecond values for a TDateTime.

DecodeDateWeek procedure
Returns the year, week of the year, and day of the week for a specified TDateTime value.

DecodeDayOfWeekInMonth procedure
For a given TDateTime value, returns the year, month, day of the week, and the count of that day of the week in the month.

DecodeTime procedure
Breaks a TDateTime value into hours, minutes, seconds, and milliseconds.

EncodeDate function function
Returns a TDateTime value that represents a specified Year, Month, and Day.

EncodeDateDay function
Returns a TDateTime that represents a specified day of the year for a specified year.

EncodeDateMonthWeek function
Returns a TDateTime that represents a specified day of a specified week in a specified month and year.

EncodeDateTime function
Returns a TDateTime that represents a specified year, month, day, hour, minute, second, and millisecond.

EncodeDateWeek function
Returns a TDateTime that represents a specified day of a specified week in a specified year.

EncodeDayOfWeekInMonth function
Returns a TDateTime that represents a specified occurrence of a day of the week within a specified month and year.

EncodeTime function
Returns a TDateTime value for a specified Hour, Min, Sec, and MSec.

EndOfADay function
Returns a TDateTime that represents the last millisecond of a specified day.

EndOfAMonth function
Returns a TDateTime that represents the last millisecond of the last day of a specified month.

EndOfAWeek function
Returns a TDateTime value that represents the last millisecond of a specified day of a specified week.

EndOfAYear function
Returns a TDateTime that represents the last millisecond of a specified year.

EndOfTheDay function
Returns a TDateTime that represents the last millisecond of the day identified by a specified TDateTime.

EndOfTheMonth function
Returns a TDateTime that represents the last millisecond of the last day of the month identified by a specified TDateTime.

EndOfTheWeek function
Returns a TDateTime that represents the last millisecond of the last day of the week identified by a specified TDateTime.

EndOfTheYear function
Returns a TDateTime that represents the last millisecond of the last day of the year identified by a specified TDateTime.

FormatDateTime function
Formats a TDateTime value.

HourOf function
Returns the hour of the day represented by a TDateTime value.

HourOfTheDay function
Returns the hour of the day represented by a TDateTime value.

HourOfTheMonth function
Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the month.

HourOfTheWeek function
Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the week.

HourOfTheYear function
Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the year.

HoursBetween function
Returns the number of whole hours between two specified TDateTime values.

HourSpan function
Returns the number of Hours (including fractional Hours) between two specified TDateTime values.

IncAMonth procedure
Increments date data by one month.

IncDay function
Returns a date shifted by a specified number of days.

IncHour function
Returns a date/time value shifted by a specified number of hours.

IncMilliSecond function
Returns a date/time value shifted by a specified number of milliseconds.

IncMinute function
Returns a date/time value shifted by a specified number of minutes.

IncMonth function
Returns a date shifted by a specified number of months.

IncSecond function
Returns a date/time value shifted by a specified number of seconds.

IncWeek function
Returns a date shifted by a specified number of weeks.

IncYear function
Returns a date shifted by a specified number of years.

IsInLeapYear function
Indicates whether a specified TDateTime value occurs in a leap year.

IsLeapYear function
Indicates whether a specified year is a leap year.

IsPM function
Indicates whether the time portion of a specified TDateTime value occurs after noon.

IsSameDay function
Indicates whether a specified TDateTime value occurs on a the same day as a criterion date.

IsToday function
Indicates whether a specified TDateTime value occurs on the current date.

IsValidDate function
Indicates whether a specified year, month, and day represent a valid date.

IsValidDateDay function
Indicates whether a specified year and day of the year represent a valid date.

IsValidDateMonthWeek function
Indicates whether a specified year, month, week of the month, and day of the week represent a valid date.

IsValidDateTime function
Indicates whether a specified year, month, day, hour, minute, second, and millisecond represent a valid date and time.

IsValidDateWeek function
Indicates whether a specified year, week of the year, and day of the week represent a valid date.

IsValidTime function
Indicates whether a specified hour, minute, second, and millisecond represent a valid date and time.

MilliSecondOf function
Returns the millisecond of the second represented by a TDateTime value.

MilliSecondOfTheDay function
Returns the number of milliseconds between a specified TDateTime value and the beginning of the same day.

MilliSecondOfTheHour function
Returns the number of milliseconds between a specified TDateTime value and the beginning of the same hour.

MilliSecondOfTheMinute function
Returns the number of milliseconds between a specified TDateTime value and the beginning of the same minute.

MilliSecondOfTheMonth function
Returns the number of milliseconds between a specified TDateTime value and the beginning of the month.

MilliSecondOfTheSecond function
Returns the millisecond of the second represented by a TDateTime value.

MilliSecondOfTheWeek function
Returns the number of milliseconds between a specified TDateTime value and 12:00:00:00 AM of the first day of the week.

MilliSecondOfTheYear function
Returns the number of milliseconds between a specified TDateTime value and 12:00:00:00 AM of the first day of the year.

MilliSecondsBetween function
Returns the number of milliseconds between two specified TDateTime values.

MilliSecondSpan function
Returns the number of milliseconds between two specified TDateTime values.

MinuteOf function
Returns the minute of the hour represented by a TDateTime value.

MinuteOfTheDay function
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the same day.

MinuteOfTheHour function
Returns the number of minutes between a specified TDateTime value and the beginning of the same hour.

MinuteOfTheMonth function
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the month.

MinuteOfTheWeek function
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the week.

MinuteOfTheYear function
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the year.

MinutesBetween function
Returns the number of minutes between two specified TDateTime values.

MinuteSpan function
Returns the number of minutes, including fractions thereof, between two specified TDateTime values.

MonthOf function
Returns the month of the year represented by a TDateTime value.

MonthOfTheYear function
Returns the month of the year represented by a TDateTime value.

MonthsBetween function
Returns the approximate number of months between two specified TDateTime values.

MonthSpan function
Returns the approximate number of months, including fractions, between two specified TDateTime values.

MSecsToTimeStamp function
Converts a specified number of milliseconds into a TTimeStamp value.

Now function
Returns the current date and time.

NthDayOfWeek function
Returns which occurrence of its weekday a specified TDateTime value represents.

NullSQLTimeStamp constant
Represents a NULL TSQLTimeStamp value.

OneHour Constant;OneMillisecond Constant;OneMinute Constant;OneSecond Constant
Delphi inverse time unit constants.

RecodeDate function
Replaces the date portion of a specified TDateTime value.

RecodeDateTime function
Selectively replaces parts of a specified TDateTime value.

RecodeDay function
Replaces the day of the month for a specified TDateTime value.

RecodeHour function
Replaces the hour of the day for a specified TDateTime value.

RecodeMilliSecond function
Replaces the millisecond of the second for a specified TDateTime value.

RecodeMinute function
Replaces the minute of the hour for a specified TDateTime value.

RecodeMonth function
Replaces the month of the year for a specified TDateTime value.

RecodeSecond function
Replaces the second of the minute for a specified TDateTime value.

RecodeTime function
Replaces the time portion of a specified TDateTime value.

RecodeYear function
Replaces the year for a specified TDateTime value.

ReplaceDate procedure
Replaces the date portion of a TDateTime value with a specified date.

ReplaceTime procedure
Replaces the time portion of a TDateTime value with a specified time.

SameDate function
Indicates whether two TDateTime values represent the same year, month, and day.

SameDateTime function
Indicates whether two TDateTime values represent the same year, month, day, hour, minute, second, and millisecond.

SameTime function
Indicates whether two TDateTime values represent the same time of day, ignoring the date portion.

SecondOf function
Returns the second of the minute represented by a TDateTime value.

SecondOfTheDay function
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM of the same day.

SecondOfTheHour function
Returns the number of seconds between a specified TDateTime value and the beginning of the same hour.

SecondOfTheMinute function
Returns the number of seconds between a specified TDateTime value and the beginning of the same minute.

SecondOfTheMonth function
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM on the first day of the month.

SecondOfTheWeek function
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM of the first day of the week.

SecondOfTheYear function
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM on the first day of the year.

SecondsBetween function
Returns the number of seconds between two specified TDateTime values.

SecondSpan function
Returns the number of seconds (including fractions thereof) between two specified TDateTime values.

SQLDayOfWeek function
Indicates the day of the week when a specified TSQLTimeStamp value occurs.

SQLTimeStampToDateTime function
Converts a TSQLTimeStamp value to a TDateTime value.

SQLTimeStampToStr function
Converts a TSQLTimeStamp value to a string.

StartOfADay function
Returns a TDateTime that represents 12:00:00:00 AM on a specified day.

StartOfAMonth function
Returns a TDateTime that represents 12:00:00:00 AM on the first day of a specified month.

StartOfAWeek function
Returns a TDateTime that represents 1the first moment on a specified day of a specified week.

StartOfAYear function
Returns a TDateTime that represents the first moment on the first day of a specified year.

StartOfTheDay function
Returns a TDateTime that represents 12:00:00:00 AM on the day identified by a specified TDateTime.

StartOfTheMonth function
Returns a TDateTime that represents 12:00:00:00 AM on the first day of the month identified by a specified TDateTime.

StartOfTheWeek function
Returns a TDateTime that represents 12:00:00:00 AM on the first day of the week identified by a specified TDateTime.

StartOfTheYear function
Returns a TDateTime that represents 12:00:00:00 AM on the first day of the year identified by a specified TDateTime.

StrToDate function
Converts a string to a TDateTime value.

StrToDateDef function
Converts a string to a TDateTime value, with error default.

StrToDateTime function
Converts a string to a TDateTime value.

StrToDateTimeDef function
Converts a string to a TDateTime value with error default.

StrToSQLTimeStamp function
Converts a string to a TSQLTimeStamp value.

StrToTime function
Converts a string to a TDateTime value.

StrToTimeDef function
Converts a string to a TDateTime value with error default.

SystemTimeToDateTime function
Converts a system time value into a TDateTime value.

Time unit constants
Represent useful values for time calculations.

Time, GetTime functions
Returns the current time.

TimeOf function
Strips the date portion from a TDateTime value.

TimeStampToDateTime function
Converts a TTimeStamp value into the corresponding TDateTime value.

TimeStampToMSecs function
Converts a TTimeStamp value into an absolute number of milliseconds.

TimeToStr function
Returns a string that represents a TDateTime value.

Today function
Returns a TDateTime value that represents the current date.

Tomorrow function
Returns a TDateTime value that represents the following day.

TryEncodeDate function
Creates a TDateTime value that represents a specified Year, Month, and Day.

TryEncodeDateDay function
Calculates the TDateTime value that represents a specified day of the year for a specified year.

TryEncodeDateMonthWeek function
Calculates the TDateTime value that represents a specified day of a specified week in a specified month and year.

TryEncodeDateTime function
Calculates the TDateTime value that represents a specified year, month, day, hour, minute, second, and millisecond.

TryEncodeDateWeek function
Calculates the TDateTime value that represents a specified day of a specified week in a specified year.

TryEncodeDayOfWeekInMonth function
Calculates a TDateTime that represents a specified occurrence of a day of the week within a specified month and year.

TryEncodeTime function
Creates a TDateTime value for a specified Hour, Min, Sec, and MSec.

TryRecodeDateTime function
Selectively replaces parts of a specified TDateTime value.

TryStrToDate function
Converts a string to a TDateTime value, with a Boolean success code.

TryStrToDateTime function
Converts a string to a TDateTime value with a Boolean success code.

TryStrToSQLTimeStamp function
Converts a string to a TSQLTimeStamp value.

TryStrToTime function
Converts a string to a TDateTime value with an error default.

UnixDateDelta constant
Specifies the difference between TDateTime and TIME_T values.

WeekOf function
Returns the week of the year represented by a TDateTime value.

WeekOfTheMonth function
Returns the week of the month represented by a TDateTime value.

WeekOfTheYear function
Returns the week of the year represented by a TDateTime value.

WeeksBetween function
Returns the number of whole weeks between two specified TDateTime values.

WeeksInAYear function
Returns the number of weeks in a specified year.

WeeksInYear function
Returns the number of weeks in the year of a specified TDateTime value.

WeekSpan function
Returns the number of weeks (including fractional weeks) between two specified TDateTime values.

WithinPastDays function
Indicates whether two dates are within a specified number of days of each other.

WithinPastHours function
Indicates whether two date/time values are within a specified number of hours of each other.

WithinPastMilliSeconds function
Indicates whether two date/time values are within a specified number of milliseconds of each other.

WithinPastMinutes function
Indicates whether two date/time values are within a specified number of minutes of each other.

WithinPastMonths function
Indicates whether two date/time values are within a specified number of months of each other.

WithinPastSeconds function
Indicates whether two date/time values are within a specified number of seconds of each other.

WithinPastWeeks function
Indicates whether two date/time values are within a specified number of weeks of each other.

WithinPastYears function
Indicates whether two date/time values are within a specified number of years of each other.

YearOf function
Returns the year represented by a TDateTime value.

YearsBetween function
Returns the approximate number of years between two specified TDateTime values.

YearSpan function
Returns the approximate number of years (including fractions thereof) between two specified TDateTime values.

Yesterday function
Returns a TDateTime value that represents the preceding day.

heGoat
меритократ

Рег.: 28.08.2002
Сообщений: 10419
Из: стойло
Рейтинг: 6576
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: Adoon]
      24.11.2006 13:28
 

а просто в хелп послать не мог?



think you are different?
heGoat
меритократ

Рег.: 28.08.2002
Сообщений: 10419
Из: стойло
Рейтинг: 6576
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: Basilio]
      24.11.2006 13:29
 

дни: DaysBetween(Event2-Event1)
часы, минуты, секунды: TimeToStr(Event2-Event1).



think you are different?
shaller
San Jose

Рег.: 25.10.2002
Сообщений: 21640
Из: Станция 074803
Рейтинг: 15646
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: heGoat]
      24.11.2006 13:31
 

>DaysBetween(Event2-Event1)

а не DaysBetween(Event2, Event1) ?



'Земля наша велика и обильна, а порядка в ней нет. Приходите княжить и владеть нами'
Basilio
GreenOne

Рег.: 14.10.2002
Сообщений: 13750
Из: Москва
Рейтинг: 3476
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: heGoat]
      24.11.2006 13:34
 

ок, спс. переправлю свой Days:=Trunc(Now-Event)

heGoat
меритократ

Рег.: 28.08.2002
Сообщений: 10419
Из: стойло
Рейтинг: 6576
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: shaller]
      24.11.2006 13:35
 

да, конечно, сорри



think you are different?
Adoon
member

Рег.: 03.11.2002
Сообщений: 149
Рейтинг: 101
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: heGoat]
      24.11.2006 13:57
 

если он с таким вопросом сюда зашел, значит хелп найти не смог
а ссылки на странички в Дельфовом хелпе я не нашел

Basilio
GreenOne

Рег.: 14.10.2002
Сообщений: 13750
Из: Москва
Рейтинг: 3476
  Re: [Delphi] Как получить разность дат в виде "дней-часов-минут-секунд [re: Adoon]
      24.11.2006 14:14
 

этот список я видел. но меня заломало его глазами искать.
основной минус справки по дельфе - нет поиска по высвечиваемой странице

Страницы: 1

Technical >> Development (Archive)

Дополнительная информация
0 зарегистрированных и 1 анонимных пользователей просматривают этот форум.

Модераторы:  DarkGray 

Печать темы

Права
      Вы можете создавать новые темы
      Вы можете отвечать на сообщения
      HTML отключен
      UBBCode включен

Рейтинг:
Просмотров темы:

Переход в