برجاء إيضاح كيفية تحويل حقل الوقت من أرقام إلى وقت بقاعدة البيانات.
مثل:
21600000إلى06:0022800000إلى06:20
شكراً.
Originally posted at https://answers.namasoft.com/question/470/ on 2018-12-04.
برجاء إيضاح كيفية تحويل حقل الوقت من أرقام إلى وقت بقاعدة البيانات.
مثل:
21600000 إلى 06:0022800000 إلى 06:20شكراً.
Originally posted at https://answers.namasoft.com/question/470/ on 2018-12-04.
إذا كنت تحتاج هذا في تقرير، فأمامك حلّان:
NamaRep.timeToString($F{fromTime}) وسيعطيك النص المطلوب مباشرة.NamaRep.timeToDecimal($F{fromTime}) لتحويل الوقت إلى رقم عشري.وإذا كان ذلك داخل القوالب (templates) فيمكنك استخدام {timetostring(fromTime)} — مع ملاحظة أن هذا الجزء متوفّر في الإصدارات بعد 2018-12-05.
أما إذا أردت التحويل مباشرة في قاعدة البيانات، فيمكن استخدام هذه المعادلة:
select tl.fromDate, tl.fromTime,
right('00'+cast(cast(((tl.fromTime+0.0)/3600000) as int) as varchar(2)),2)
+ ':' +
right('00'+cast(cast(Round((((tl.fromTime+0.0)/3600000)-cast((tl.fromTime+0.0)/3600000 as int))*60,0) as int) as varchar(2)),2) fTime
from TimeAttendanceLine tl
وقامت بالنتيجة الموضحة في الصورة:

واستعلام كامل لحساب الفرق (المدة) أيضاً:
select tl.fromDate,
right('00'+cast(cast(((tl.fromTime+0.0)/3600000) as int) as varchar(2)),2)
+ ':' +
right('00'+cast(cast(Round((((tl.fromTime+0.0)/3600000)-cast((tl.fromTime+0.0)/3600000 as int))*60,0) as int) as varchar(2)),2) fTime,
tl.toDate,
right('00'+cast(cast(((tl.toTime+0.0)/3600000) as int) as varchar(2)),2)
+ ':' +
right('00'+cast(cast(Round((((tl.toTime+0.0)/3600000)-cast((tl.toTime+0.0)/3600000 as int))*60,0) as int) as varchar(2)),2) tTime,
right('00'+cast(cast(((tl.toTime-tl.fromTime+0.0)/3600000) as int) as varchar(2)),2)
+ ':' +
right('00'+cast(cast(Round((((tl.toTime-tl.fromTime+0.0)/3600000)-cast((tl.toTime-tl.fromTime+0.0)/3600000 as int))*60,0) as int) as varchar(2)),2) spentTime
from TimeAttendanceLine tl
Originally posted at https://answers.namasoft.com/question/470/ on 2018-12-05.