1

كيفية تحويل حقل الوقت من أرقام الى وقت بقاعدة البيانات

برجاء إيضاح كيفية تحويل حقل الوقت من أرقام الى وقت بقاعدة البيانات
مثل 21600000
الى 06:00
و 22800000
الى 06:20

شكرا

Abdelrahman's avatar
101
Abdelrahman
asked 2018-12-04 00:56:12 +0200
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

تم إستخدام هذه المعادلة

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


و قامت بالتالى
image description

إستعلام كامل لحساب الفرق أيضا:

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
Abdelrahman's avatar
101
Abdelrahman
answered 2018-12-04 02:14:38 +0200
Ahmed Qasid's avatar
5.8k
Ahmed Qasid
updated 2018-12-05 04:32:50 +0200
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

If you need this for a report, then you have two solutions:

  1. You can use NamaRep.timeToString($F{fromTime}) and this will give you the desired string directly.
  2. You can also use NamaRep.timeToDecimal($F{fromTime}) and this will convert the time to a decimal

If in templates, you can use {timetostring(fromTime)} -> Please note this part is found in releases after 20181205

Ahmed Qasid's avatar
5.8k
Ahmed Qasid
answered 2018-12-05 04:42:00 +0200, updated 2018-12-05 10:54:29 +0200
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Login/Signup to Answer