البرمجة

مقارنة تاريخ مع تاريخ محدد في VBScript

To check if a date is greater than a specified date in VBScript, you can use the DateDiff function. Here’s an example:

vb
Dim Jun16 Jun16 = CDate("June 16, 2016") Dim SelectedDate SelectedDate = CDate(Session("month") & "-" & Session("yrs")) If DateDiff("d", Jun16, SelectedDate) > 0 Then grossinc = CInt(rset1("othermontize_benefit")) + CInt(rset1("basic")) + CInt(rset1("house")) + CInt(rset1("utility")) Else grossinc = CInt(rset1("gross")) + CInt(rset1("bonus")) + CInt(rset1("arrears")) + CInt(rset1("ot")) End If

In this code snippet, Jun16 is set to the date “June 16, 2016”, and SelectedDate is set to the date constructed from the values in the Session variables “month” and “yrs”. The DateDiff function calculates the difference in days between Jun16 and SelectedDate. If the result is greater than 0, it means SelectedDate is greater than Jun16. Otherwise, it’s not.

Please note that CDate is used to convert the date strings into date values, and CInt is used to convert the string values from rset1 into integers for addition. Adjust the date formats and variable names as needed for your specific scenario.

المزيد من المعلومات

في VBScript، يمكنك استخدام الدالة DateDiff لمقارنة تاريخ مع تاريخ محدد. الدالة DateDiff تقوم بحساب الفارق بين تاريخين في وحدة زمنية محددة مثل الأيام أو الشهور أو السنوات.

لمقارنة تاريخ مع تاريخ محدد، يمكنك استخدام الدالة كالتالي:

vb
Dim currentDate currentDate = Now ' تاريخ اليوم Dim specifiedDate specifiedDate = CDate("2024-03-10") ' تاريخ محدد If DateDiff("d", currentDate, specifiedDate) > 0 Then ' تاريخ اليوم أحدث من التاريخ المحدد Else ' التاريخ المحدد أحدث من تاريخ اليوم أو هما متساويان End If

في هذا المثال، يتم مقارنة تاريخ اليوم currentDate مع تاريخ محدد specifiedDate. إذا كانت القيمة المُعادة من DateDiff أكبر من صفر، فهذا يعني أن تاريخ اليوم أحدث من التاريخ المحدد.

مقالات ذات صلة

زر الذهاب إلى الأعلى
إغلاق

أنت تستخدم إضافة Adblock

يرجى تعطيل مانع الإعلانات حيث أن موقعنا غير مزعج ولا بأس من عرض الأعلانات لك فهي تعتبر كمصدر دخل لنا و دعم مقدم منك لنا لنستمر في تقديم المحتوى المناسب و المفيد لك فلا تبخل بدعمنا عزيزي الزائر