![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Дата. [D6, WinXP]
Andy BitOff © (2004-12-23 18:52:00)Как из сторки:
var
m,y:string;
begin
m:='Ноябрь';
y:='2004';
end;
Получить TDateTime?
Ega23 (2004-12-23 19:24:00) [1]
function YearAndMonthToDateTime(const aYear, aMonth :String):TDateTime;
function StrMonthToInt(aStr:String):Integer;
begin
if (Str='ЯНВАРЬ') then result:=1
else
if (Str='ФЕВРАЛЬ') then result:=2
else
if (Str='МАРТ') then result:=3
else
if (Str='АПРЕЛЬ') then result:=4
else
if (Str='МАЙ') then result:=5
else
if (Str='ИЮНЬ') then result:=6
else
if (Str='ИЮЛЬ') then result:=7
else
if (Str='АВГУСТ') then result:=8
else
if (Str='СЕНТЯБРЬ') then result:=9
else
if (Str='ОКТЯБРЬ') then result:=10
else
if (Str='НОЯБРЬ') then result:=11
else
if (Str='ДЕКАБРЬ') then result:=12
else Result:=0;
end;
var
MonthStr:String;
Month, Year:Word;
Code:Integer;
begin
Result:=0;
MonthStr:=Trim(ANSIUpperCase(aMonth));
Val(aYear, Year, Code);
if Code<>0 then Exit;
Month:=StrMonthToInt(MonthStr);
if Month=0 then Exit;
Result:=EncodeDate(Year, Month, 1);
end;
Писал прямо здесь, возможны ошибки. Хотя, вроде, всё верно...
Anatoly Podgoretsky (2004-12-23 19:20:00) [2]Преобразуй строки в число и EncodeDate
Andy BitOff (2004-12-23 19:12:00) [3]Всеравно. Это только месяц и соответственно любое число месяца. Это не принципиально.
Ega23 (2004-12-23 18:56:00) [4]А что считать TdateTime?
38288 или 38259? (01.10.2004 и 30.10.2004)