נכתב ע"י שמח לעזור;988952:זה עניין של פורמט, הוא באמת מחשבן גם את הימים.
אתה צריך לשרשר ביטוי, שבו חשבון הפרש התאריכים בין הסיכום לבין 30/12/1899 (תאריך הפתיחה של אקסס), ואת זה תעצב בימים, ואח"כ סיכום רגיל ייתן לך את השעות.
Sub test()
Dim dtStartDate As Date
Dim dtEndDate As Date
dtStartDate = #4/18/2013 11:10:59 PM#
dtEndDate = #4/19/2013 12:29:49 AM#
Debug.Print Format(DateDiff("h", dtStartDate, dtEndDate), "00") _
& ":" & _
Format(DateDiff("n", dtStartDate, dtEndDate) Mod 60, "00") _
& ":" & _
Format(DateDiff("s", dtStartDate, dtEndDate) Mod 60, "00")
End Sub
Option Explicit
Declare Function GetProfileString Lib "kernel32.dll" Alias "GetProfileStringA" _
(ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Public Function GetTimeDelimiter() As String
Const conMaxSize = 10
Dim strBuffer As String
Dim intLen As Integer
strBuffer = Space(conMaxSize)
intLen = GetProfileString("intl", "sTime", "", strBuffer, conMaxSize)
GetTimeDelimiter = Left(strBuffer, intLen)
End Function
Function fCustomDateDiff(dtStartDate As Date, dtEndDate As Date, _
Optional strFormat As String = "H:MM:SS") As String
' Return the difference between two times,
' formatted as specified in strFormat.
Dim lngSeconds As Long
Dim sngMinutes As Single
Dim sngHours As Single
Dim sngDays As Single
Dim intSeconds As Integer
Dim intMinutes As Integer
Dim intHours As Integer
Dim intRoundedHours As Integer
Dim intRoundedMinutes As Integer
Dim strDay As String
Dim strHour As String
Dim strMinute As String
Dim strSecond As String
Dim strOut As String
Dim lngFullDays As Long
Dim lngFullHours As Long
Dim lngFullMinutes As Long
Dim strDelim As String
' If you don't want to use the local delimiter,
' but a specific one, replace the next line with
' this:
' strDelim = ":"
strDelim = GetTimeDelimiter()
' Calculate the full number of seconds in the interval.
' This limits the calculation to 2 billion seconds
' (68 years or so), but that's not too bad. Then calculate
' the difference in minutes, hours, and days, as well.
lngSeconds = DateDiff("s", dtStartDate, dtEndDate)
sngMinutes = lngSeconds / 60
sngHours = sngMinutes / 60
sngDays = sngHours / 24
' Get the full hours and minutes, for later display.
lngFullDays = Int(sngDays)
lngFullHours = Int(sngHours)
lngFullMinutes = Int(sngMinutes)
' Get the incremental amount of each unit.
intHours = Int((sngDays - lngFullDays) * 24)
intMinutes = Int((sngHours - lngFullHours) * 60)
intSeconds = CInt((sngMinutes - lngFullMinutes) * 60)
' In some instances, time values must be rounded.
' The next two lines depend on the fact that a true statement
' has a value of -1 and a false statement has a value of 0.
' The code needs to add 1 to the value if the following
' expression is true, and 0 if not.
intRoundedHours = intHours - (intMinutes > 30)
intRoundedMinutes = intMinutes - (intSeconds > 30)
strDay = "ימים"
strHour = "שעות"
strMinute = "דקות"
strSecond = "שניות"
If lngFullDays = 1 Then strDay = "יום"
Select Case strFormat
Case "D H"
If intRoundedHours = 1 Then strHour = "שעה"
strOut = lngFullDays & " " & strDay & " " & _
intRoundedHours & " " & strHour
Case "D H M"
If intHours = 1 Then strHour = "שעה"
If intRoundedMinutes = 1 Then strMinute = "דקה"
strOut = lngFullDays & " " & strDay & " " & _
intHours & " " & strHour & " " & _
intRoundedMinutes & " " & strMinute
Case "D H M S"
If intHours = 1 Then strHour = "שעה"
If intMinutes = 1 Then strMinute = "דקה"
If intSeconds = 1 Then strSecond = "שניה"
strOut = lngFullDays & " " & strDay & " " & _
intHours & " " & strHour & " " & _
intMinutes & " " & strMinute & " " & _
intSeconds & " " & strSecond
Case "D H:MM" ' 3 ימים 2:46"
strOut = lngFullDays & " " & strDay & " " & _
intHours & strDelim & Format(intRoundedMinutes, "00")
Case "D HH:MM" ' 3 ימים 02:46"
strOut = lngFullDays & " " & strDay & " " & _
Format(intHours, "00") & strDelim & _
Format(intRoundedMinutes, "00")
Case "D HH:MM:SS" ' 3 ימים 02:45:45"
strOut = lngFullDays & " " & strDay & " " & _
Format(intHours, "00") & strDelim & _
Format(intMinutes, "00") & strDelim & _
Format(intSeconds, "00")
Case "H M" ' 74 שעות 46 דקות"
If lngFullHours = 1 Then strHour = "שעה"
If intRoundedMinutes = 1 Then strMinute = "דקה"
strOut = lngFullHours & " " & strHour & " " & _
intRoundedMinutes & " " & strMinute
Case "H:MM" ' 74:46
strOut = lngFullHours & strDelim & _
Format(intRoundedMinutes, "00")
Case "H:MM:SS" ' 74:45:45
strOut = lngFullHours & strDelim & _
Format(intMinutes, "00") & strDelim & _
Format(intSeconds, "00")
Case "M S" ' 4485 דקות 45 שניות
If lngFullMinutes = 1 Then strMinute = "דקה"
If intSeconds = 1 Then strSecond = "שניה"
strOut = lngFullMinutes & " " & strMinute & " " & _
intSeconds & " " & strSecond
Case "M:SS" ' 4485:45
strOut = lngFullMinutes & strDelim & _
Format(intSeconds, "00")
Case Else
strOut = ""
End Select
fCustomDateDiff = strOut
End Function
Sub TestInterval()
Dim dtStartDate As Date
Dim dtEndDate As Date
dtStartDate = #4/18/2013 11:10:59 PM#
dtEndDate = #4/19/2013 12:29:49 AM#
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "D H")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "D H M")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "D H M S")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "D H:MM")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "D HH:MM")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "D HH:MM:SS")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "H M")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "H:MM")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "H:MM:SS")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "M S")
Debug.Print fCustomDateDiff(dtStartDate, dtEndDate, "M:SS")
End Sub
Public Function fCalculateWages(strFormattedTime As String, _
curHourlyWage As Currency, _
Optional blnIncludeSeconds As Boolean = True) As Currency
Dim arr As Variant
Dim intHours, intMinutes, intSeconds As Integer
Dim intTemp As Integer
arr = Split(strFormattedTime, ":")
intHours = CCur(arr(0)) * 3600
intMinutes = CCur(arr(1)) * 60
intSeconds = CCur(arr(2))
intTemp = IIf(blnIncludeSeconds = True, intHours + intMinutes + intSeconds, intHours + intMinutes)
fCalculateWages = intTemp * curHourlyWage / 3600
End Function
נכתב ע"י תמנתי;990012:...
אני מעלה סתם דוגמא לאיך זה נראה.
אני לא יודעת תכנות ולכן עושה זאת בצורה פשוטה כזו
נכתב ע"י יעילות;990366:מצ''ב קובץ באקסל קרדיט למיכאל אבידן מנהל פורום אופיס בתפוז וhttp://www.tapuz.co.il/Forums2008/ForumPage.aspx?ForumId=62&r=1לפורום http://www.mabat3.co.il/phpBB3/index.phpשתיווך ביננו.
נכתב ע"י moishy;990401:תעלה לכאן דוגמא, ובל"נ אעשה את השינויים הנדרשים.
rhon.co.il
מעכשיו, תהיו הראשונים לקבל את כל העדכונים, החדשות, ההפתעות בלעדיות, והתכנים הכי חמים שלנו בפרוג!
חלה שגיאה בשליחה. נסו שוב!
לוח לימודים
מסלולי לימוד שאפשר להצטרף
אליהם ממש עכשיו:
תהילים פרק כה
אלְדָוִד אֵלֶיךָ יי נַפְשִׁי אֶשָּׂא:באֱלֹהַי בְּךָ בָטַחְתִּי אַל אֵבוֹשָׁה אַל יַעַלְצוּ אֹיְבַי לִי:גגַּם כָּל קוֶֹיךָ לֹא יֵבֹשׁוּ יֵבֹשׁוּ הַבּוֹגְדִים רֵיקָם:דדְּרָכֶיךָ יי הוֹדִיעֵנִי אֹרְחוֹתֶיךָ לַמְּדֵנִי:ההַדְרִיכֵנִי בַאֲמִתֶּךָ וְלַמְּדֵנִי כִּי אַתָּה אֱלֹהֵי יִשְׁעִי אוֹתְךָ קִוִּיתִי כָּל הַיּוֹם:וזְכֹר רַחֲמֶיךָ יי וַחֲסָדֶיךָ כִּי מֵעוֹלָם הֵמָּה:זחַטֹּאות נְעוּרַי וּפְשָׁעַי אַל תִּזְכֹּר כְּחַסְדְּךָ זְכָר לִי אַתָּה לְמַעַן טוּבְךָ יי:חטוֹב וְיָשָׁר יי עַל כֵּן יוֹרֶה חַטָּאִים בַּדָּרֶךְ:טיַדְרֵךְ עֲנָוִים בַּמִּשְׁפָּט וִילַמֵּד עֲנָוִים דַּרְכּוֹ:יכָּל אָרְחוֹת יי חֶסֶד וֶאֱמֶת לְנֹצְרֵי בְרִיתוֹ וְעֵדֹתָיו:יאלְמַעַן שִׁמְךָ יי וְסָלַחְתָּ לַעֲוֹנִי כִּי רַב הוּא:יבמִי זֶה הָאִישׁ יְרֵא יי יוֹרֶנּוּ בְּדֶרֶךְ יִבְחָר:יגנַפְשׁוֹ בְּטוֹב תָּלִין וְזַרְעוֹ יִירַשׁ אָרֶץ:ידסוֹד יי לִירֵאָיו וּבְרִיתוֹ לְהוֹדִיעָם:טועֵינַי תָּמִיד אֶל יי כִּי הוּא יוֹצִיא מֵרֶשֶׁת רַגְלָי:טזפְּנֵה אֵלַי וְחָנֵּנִי כִּי יָחִיד וְעָנִי אָנִי:יזצָרוֹת לְבָבִי הִרְחִיבוּ מִמְּצוּקוֹתַי הוֹצִיאֵנִי:יחרְאֵה עָנְיִי וַעֲמָלִי וְשָׂא לְכָל חַטֹּאותָי:יטרְאֵה אוֹיְבַי כִּי רָבּוּ וְשִׂנְאַת חָמָס שְׂנֵאוּנִי:כשָׁמְרָה נַפְשִׁי וְהַצִּילֵנִי אַל אֵבוֹשׁ כִּי חָסִיתִי בָךְ:כאתֹּם וָיֹשֶׁר יִצְּרוּנִי כִּי קִוִּיתִיךָ:כבפְּדֵה אֱלֹהִים אֶת יִשְׂרָאֵל מִכֹּל צָרוֹתָיו:
הנושאים החמים