أحمد العيسى قام بنشر سبتمبر 5, 2024 قام بنشر سبتمبر 5, 2024 (معدل) السلام عليكم الكود التالى هو الذى أستخدمه لإيجاد الفرق بين تاريخ الميلاد وتاريخ اليوم ليخرج عمر الموظف باليوم والشهر والسنة كذلك يتم استخدامه لإيجاد الفرق بين تاريخ الإحالة للمعاش وتاريخ اليوم ليخرج الزمن المتبقى على الخروج باليوم والشهر والسنة لأننى أحياناً أجد فرق يوم بين استخدام هذا الكود وبين الحساب اليدوى كما تعودنا قديماً Function d_ay(Calculate As Date, birth As Date) As Integer Dim m_on As Integer m_on = DateDiff("m", birth, Calculate) d_ay = DateDiff("d", DateAdd("m", m_on, birth), Calculate) If d_ay < 0 Then m_on = m_on - 1 d_ay = DateDiff("d", DateAdd("m", m_on, birth), Calculate) End If End Function Function m_on(Calculate As Date, birth As Date) As Integer Dim d_ay As Integer m_on = DateDiff("m", birth, Calculate) d_ay = DateDiff("d", DateAdd("m", m_on, birth), Calculate) If d_ay < 0 Then m_on = m_on - 1 End If m_on = m_on Mod 12 End Function Function y_er(Calculate As Date, birth As Date) As Integer Dim m_on As Integer, d_ay As Integer m_on = DateDiff("m", birth, Calculate) d_ay = DateDiff("d", DateAdd("m", m_on, birth), Calculate) If d_ay < 0 Then m_on = m_on - 1 End If y_er = m_on \ 12 End Function مرفق ملف مختصر للملف الأصلى به الكود المراد التعقيب عليه db1.mdb تم تعديل سبتمبر 5, 2024 بواسطه أحمد العيسى
تمت الإجابة أحمد العيسى قام بنشر سبتمبر 5, 2024 الكاتب تمت الإجابة قام بنشر سبتمبر 5, 2024 وجدت " كود " كنت قد استخدمته فى برنامج أكسل ويعتبر متوافق 100% مع الطريقة التقليدية فى حساب الفرق بين تاريخين بوضعهما يدوياً اسفل بعضهما ويتم الطرح مباشرة أو بالإستلاف Function d_ay(Calculate As Date, birth As Date) As Integer If Day(Calculate) >= Day(birth) Then d_ay = Day(Calculate) - Day(birth) Else d_ay = Day(Calculate) + 30 - Day(birth) End If End Function Function m_on(Calculate As Date, birth As Date) As Integer If Day(Calculate) >= Day(birth) Then If Month(Calculate) >= Month(birth) Then m_on = Month(Calculate) - Month(birth) Else m_on = Month(Calculate) + 12 - Month(birth) End If Else If Month(Calculate) > Month(birth) Then m_on = Month(Calculate) - 1 - Month(birth) Else m_on = Month(Calculate) + 11 - Month(birth) End If End If End Function Function y_er(Calculate As Date, birth As Date) As Integer If Day(Calculate) >= Day(birth) Then If Month(Calculate) >= Month(birth) Then y_er = Year(Calculate) - Year(birth) Else y_er = Year(Calculate) - 1 - Year(birth) End If Else If Month(Calculate) > Month(birth) Then y_er = Year(Calculate) - Year(birth) Else y_er = Year(Calculate) - 1 - Year(birth) End If End If End Function
الردود الموصى بها
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.