المشاركات : 37
المواضيع 21
:
: 0
الإنتساب : Sep 2011
تحويل الوقت -ساعة -دقيقة-ثواني الى رقم اي integer حتى نقوم بجمعها وتحصيل مجموع عدد الساعات
علماً ان عند جمع الوقت في حقل من جدول يجمع الوقت ولكن بما انه من نوع tdatetime
فانه يعمل في مجال 24 وبعد الجمع ال24 ساعة مع 1ساعة فانه يعرض 01.00.00 بدلا من 25.00.00 فلا يقوم بل الجمع بشكل صحيح فكيف التويحل الى نوع بيانات integer لجمع بشكل صحيح وشكراً لتعاونكم
المشاركات : 3,703
المواضيع 101
:
: 579
الإنتساب : Feb 2008
السلام عليكم ورحمة الله
إقتباس :من نوع tdatetime
... يعرض 01.00.00 بدلا من 25.00.00 فلا يقوم بل الجمع بشكل صحيح
TDateTime يحتوى التاريخ و الزمن معا
الجمع صحيح
عدد الساعات فاق 24 فاصبح يوم
مثلما يفوق عدد الثواني 60 فيصبح دقيقة
أحد الطرق استخدام DecodeDateTime ( راجع الوحدة DateUtils )للحصول على الثواني/الدقائق/الساعات/ الايام/الشهر/السنة ثم عرضها كما تشاء،
المشاركات : 418
المواضيع 50
:
: 0
الإنتساب : Sep 2009
ا[color="purple"]
ن الحساب للزمن سواء عملية الجمع او الطرح تتبع طريقة الترتيب بتوزيع الناتج
حسب قيمتة الزمنية فأذا تعداها يضاف الى القيمة الاعلى
فكل نوع لة بداية ونهاية عددية لا يمكن تغيرها الى ان تصل الى السنوات وهنا يمكن ان يكون رقم غير محدود
ويمكن يكون قرون غير محدود[/color]
هذا مثال لاستخدام الزمن
كود :
procedure TForm1.Button1Click(Sender: TObject);
var
fromdate, toDate: TDateTime;
begin
label1.Caption := IntToStr(YearsBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' Years' + #$A#$D +
IntToStr(MonthsBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' Months' + #$A#$D +
IntToStr(WeeksBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' Weeks' + #$A#$D +
IntToStr(DaysBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' Days' + #$A#$D +
IntToStr(HoursBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' Hours' + #$A#$D +
IntToStr(MinutesBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' Minutes' + #$A#$D +
IntToStr(SecondsBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' Seconds' + #$A#$D +
IntToStr(MilliSecondsBetween(AdvDateTimePicker2.DateTime,
AdvDateTimePicker1.DateTime)) + ' MilliSeconds' + #$A#$D
// + IntToStr (CompareDate (AdvDateTimePicker2.DateTime, AdvDateTimePicker1.DateTime))
;
end;
form1
كود :
object Form1: TForm1
Left = 501
Top = 119
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'Form1'
ClientHeight = 336
ClientWidth = 481
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poDesigned
OnShow = Button1Click
PixelsPerInch = 96
TextHeight = 13
object label1: TLabel
Left = 190
Top = 131
Width = 6
Height = 24
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -21
Font.Name = 'Nasalization'
Font.Style = [fsBold]
ParentFont = False
end
object Label2: TLabel
Left = 12
Top = 88
Width = 128
Height = 24
Caption = 'Current Date'
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -21
Font.Name = 'Nasalization'
Font.Style = [fsBold]
ParentFont = False
end
object Label3: TLabel
Left = 14
Top = 58
Width = 142
Height = 24
Caption = 'Previous Date'
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -21
Font.Name = 'Nasalization'
Font.Style = [fsBold]
ParentFont = False
end
object Label6: TLabel
Left = 0
Top = 0
Width = 481
Height = 49
Align = alTop
Alignment = taCenter
AutoSize = False
Caption = 'SLT TT MONDE'
Color = clGray
Font.Charset = ANSI_CHARSET
Font.Color = clWhite
Font.Height = -24
Font.Name = 'Nasalization'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
Layout = tlCenter
ExplicitLeft = -8
ExplicitTop = -8
end
object Button1: TButton
Left = 14
Top = 143
Width = 153
Height = 25
Caption = 'cALCULER'
TabOrder = 0
OnClick = Button1Click
end
object AdvDateTimePicker1: TAdvDateTimePicker
Left = 165
Top = 63
Width = 186
Height = 21
Date = 40766.870509259260000000
Format = 'dd/MM/yyyy'
Time = 40766.870509259260000000
DoubleBuffered = True
Kind = dkDateTime
ParentDoubleBuffered = False
ParentShowHint = False
ShowHint = False
TabOrder = 1
OnChange = Button1Click
BorderStyle = bsSingle
Ctl3D = True
DateTime = 40766.870509259260000000
TimeFormat = 'HH:mm:ss'
Version = '1.1.0.2'
LabelFont.Charset = DEFAULT_CHARSET
LabelFont.Color = clWindowText
LabelFont.Height = -11
LabelFont.Name = 'Tahoma'
LabelFont.Style = []
end
object AdvDateTimePicker2: TAdvDateTimePicker
Left = 165
Top = 90
Width = 186
Height = 21
Date = 40766.870509259260000000
Format = 'dd/MM/yyyy'
Time = 40766.870509259260000000
DoubleBuffered = True
Kind = dkDateTime
ParentDoubleBuffered = False
ParentShowHint = False
ShowHint = False
TabOrder = 2
OnChange = Button1Click
BorderStyle = bsSingle
Ctl3D = True
DateTime = 40766.870509259260000000
TimeFormat = 'HH:mm:ss'
Version = '1.1.0.2'
LabelFont.Charset = DEFAULT_CHARSET
LabelFont.Color = clWindowText
LabelFont.Height = -11
LabelFont.Name = 'Tahoma'
LabelFont.Style = []
end
object XPManifest1: TXPManifest
Left = 424
Top = 216
end
end
المشاركات : 37
المواضيع 21
:
: 0
الإنتساب : Sep 2011
شكراً لكم اخوتي واتمنى لكم دوام النجاح والتقدم
نور الله لكم طريق التفوق الف شكر