Table of Content
HAL Forum
function string DateToString (
Var Date TheDate,String FormStr)
Description:
Converts a given date from date format to string. Convertion format is specified as a string where M - months, D - days, Y - years. If months represented as MMM, month name will be returned.
Parameters:
TheDate Date to convert
FormStr Format of the date
external function Integer DaysInMonth(Integer,Integer);

procedure ChangeDatePeriod(Date td,var string StartDateStr, var string EndDateStr)
begin
  longint days;
  
  date sd,ed;

  days = DaysInMonth(td.Year,td.Month); // gets number of days in a give date
  
  sd = AddDay(td,-td.Day+1); // gets the first date of the month for a given date
  ed = AddDay(sd,days-1); // gets the last date of the month for a given date

  StartDateStr = DateToString(sd,"DD.MM.YYYY"); // converts date sd to string StartDateStr
  EndDateStr = DateToString(ed,"DD.MM.YYYY"); // converts date ed to string EndDateStr

return;
end;
Related topics:
««