accdbExe

accdbExe
لینک سایر سایت‌های آموزش Access

اطلاعات تماس و ارسال نظر

شروع کار از: فروردین 1402

Date/Time


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Date
Returns a Variant (Date) containing the current system date.
Syntax
Date
Remarks
To set the system date, use the Date statement.
Date, and if the calendar is Gregorian, Date$ behavior is unchanged by the Calendar property setting. If the
calendar is Hijri, Date$ returns a 10-character string of the form mm-dd-yyyy, where mm (01-12), dd (01-30)
and yyyy (1400-1523) are the Hijri month, day and year. The equivalent Gregorian range is Jan 1, 1980 through
Dec 31, 2099.
Example:
Dim s as Date
S = Date
Label1 = s


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Time
Sets the system time.
Syntax
Time = time
The required time argument is any numeric expression, string expression, or any combination, that can represent
a time.
Remarks
If time is a string, Time attempts to convert it to a time using the time separators you specified for your system.
If it can't be converted to a valid time, an error occurs.
Example:
Private Sub Form_Load()
Dim s As Date
s = Time
Label1 = s
End Sub
‘Displays the Time in label1


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Now
Returns a Variant (Date) specifying the current date and time according your computer's system date and time.
Syntax
Now
Example:
Private Sub Form_Load()
Dim s As Date
s = Now
Label1 = s
End Sub
‘Displays the date and time in label1


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Timer
Timers execute code repeatedly according to the Interval you specify. Set the Interval property in milliseconds.
For example, 2000 = 2 seconds. Timers are useful for checking programs conditions periodically, but don't get
in the habit of using them for everything. A Timer control is not a clock and should not be relied upon to keep
accurate time.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


DateAdd
Returns a Variant (Date) containing a date to which a specified time interval has been added.
Syntax
DateAdd(interval, number, date)
The DateAdd function syntax has these named arguments:
Part Description
interval Required. String expression that is the interval of time you want to add.
number Required. Numeric expression that is the number of intervals you want to add. It can be
positive (to get dates in the future) or negative (to get dates in the past).
date Required. Variant (Date) or literal representing date to which the interval is added.
Settings
The interval argument has these settings:
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
Remarks
You can use the DateAdd function to add or subtract a specified time interval from a date. For example, you
can use DateAdd to calculate a date 30 days from today or a time 45 minutes from now.
To add days to date, you can use Day of Year ("y"), Day ("d"), or Weekday ("w").
Example:
DateAdd("m", 1, "31-Jan-95")
In this case, DateAdd returns 28-Feb-95, not 31-Feb-95. If date is 31-Jan-96, it returns 29-Feb-96 because 1996
is a leap year.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


DateDiff
Returns a Variant (Long) specifying the number of time intervals between two specified dates.
Syntax
DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
The DateDiff function syntax has these named arguments:
Part Description
interval Required. String expression that is the interval of time you use to calculate
the difference between date1 and date2.
date1, date2 Required; Variant (Date). Two dates you want to use in the calculation.
firstdayofweek Optional. A constant that specifies the first day of the week. If not specified,
Sunday is assumed.
firstweekofyear Optional. A constant that specifies the first week of the year. If not specified,
the first week is assumed to be the week in which January 1 occurs.
Settings
The interval argument has these settings:
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
The firstdayofweek argument has these settings:
Constant Value Description
vbUseSystem 0 Use the NLS API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday
Constant Value Description
vbUseSystem 0 Use the NLS API setting.
vbFirstJan1 1 Start with week in which January 1
occurs (default).
vbFirstFourDays 2 Start with the first week that has at
least four days in the new year.
vbFirstFullWeek 3 Start with first full week of the year.
Remarks
You can use the DateDiff function to determine how many specified time intervals exist between two dates. For
example, you might use DateDiff to calculate the number of days between two dates, or the number of weeks
between today and the end of the year.
Example:
Dim TheDate As Date ' Declare variables.
Dim Msg
TheDate = InputBox("Enter a date")
Msg = "Days from today: " & DateDiff("d", Now, TheDate)
MsgBox Msg
‘Displays difference between dates in number of days


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


DateSerial
Returns a Variant (Date) for a specified year, month, and day.
Syntax
DateSerial(year, month, day)
The DateSerial function syntax has these named arguments:
Part Description
year Required; Integer. Number between 100 and 9999, inclusive, or a numeric
expression.
month Required; Integer. Any numeric expression.
day Required; Integer. Any numeric expression.
Remarks
To specify a date, such as December 31, 1991, the range of numbers for each DateSerial argument should be in
the accepted range for the unit; that is, 1–31 for days and 1–12 for months. However, you can also specify
relative dates for each argument using any numeric expression that represents some number of days, months, or
years before or after a certain date.
Example:
Dim MyDate
' MyDate contains the date for February 12, 1969.
MyDate = DateSerial(1969, 2, 12) ' Return a date.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


DateValue
Returns a Variant (Date).
Syntax
DateValue(date)
The required date argument is normally a string expression representing a date from January 1, 100 through
December 31, 9999. However, date can also be any expression that can represent a date, a time, or both a date
and time, in that range.
Remarks
If date is a string that includes only numbers separated by valid date separators, DateValue recognizes the order
for month, day, and year according to the Short Date format you specified for your system. DateValue also
recognizes unambiguous dates that contain month names, either in long or abbreviated form. For example, in
addition to recognizing 12/30/1991 and 12/30/91, DateValue also recognizes December 30, 1991 and Dec 30,
1991.
Example:
Dim MyDate
MyDate = DateValue("February 12, 1969") ' Returns 12/02/1965


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Year
Returns a Variant (Integer) containing a whole number representing the year.
Syntax
Year(date)
The required date argument is any Variant, numeric expression, string expression, or any combination, that can
represent a date. If date contains Null, Null is returned.
Example:
Dim MyDate, MyYear
MyDate = #February 12, 1969# ' Assign a date.
MyYear = Year(MyDate) ' MyYear contains 1969.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Month
Returns a Variant (Integer) specifying a whole number between 1 and 12, inclusive, representing the month of
the year.
Syntax
Month(date)
The required date argument is any Variant, numeric expression, string expression, or any combination, that can
represent a date. If date contains Null, Null is returned.
Example:
Dim MyDate, MyMonth
MyDate = #February 12, 1969# ' Assign a date.
MyMonth = Month(MyDate) ' MyMonth contains 2.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


MonthName
Returns a string indicating the specified month.
Syntax
MonthName(month[, abbreviate])
The MonthName function syntax has these parts:
Part Description
month Required. The numeric designation of the month. For example, January is 1, February
is 2, and so on.
abbreviate Optional. Boolean value that indicates if the month name is to be abbreviated. If
omitted, the default is False, which means that the month name is not abbreviated.
Example:
Private Sub Form_Load()
Label1 = MonthName(11)
End Sub
‘Returns November


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


WeekDayName
Returns a string indicating the specified day of the week.
Syntax
WeekdayName(weekday, abbreviate, firstdayofweek)
The WeekdayName function syntax has these parts:
Part Description
weekday Required. The numeric designation for the day of the week. Numeric value of each
day depends on setting of the firstdayofweek setting.
abbreviate Optional. Boolean value that indicates if the weekday name is to be abbreviated. If
omitted, the default is False, which means that the weekday name is not
abbreviated.
firstdayofweek Optional. Numeric value indicating the first day of the week. See Settings section
for values.
Settings
The firstdayofweek argument can have the following values:
Constant Value Description
vbUseSystem 0 Use National Language Support (NLS) API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday
Example:
Label1 = WeekdayName(3)
‘Returns Wednesday


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Day
Returns a Variant (Integer) specifying a whole number between 1 and 31, inclusive, representing the day of the
month.
Syntax
Day(date)
The required date argument is any Variant, numeric expression, string expression, or any combination, that can
represent a date. If date contains Null, Null is returned.
Example:
Dim MyDate, MyDay
MyDate = #February 12, 1969# ' Assign a date.
MyDay = Day(MyDate) ' MyDay contains 12.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Hour
Returns a Variant (Integer) specifying a whole number between 0 and 23, inclusive, representing the hour of
the day.
Syntax
Hour(time)
The required time argument is any Variant, numeric expression, string expression, or any combination, that can
represent a time. If time contains Null, Null is returned.
Example:
Dim MyTime, MyHour
MyTime = #4:35:17 PM# ' Assign a time.
MyHour = Hour(MyTime) ' MyHour contains 16.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Minute
Returns a Variant (Integer) specifying a whole number between 0 and 59, inclusive, representing the minute of
the hour.
Syntax
Minute(time)
The required time argument is any Variant, numeric expression, string expression, or any combination, that can
represent a time. If time contains Null, Null is returned.
Example:
Dim MyTime, MyMinute
MyTime = #4:35:17 PM# ' Assign a time.
MyMinute = Minute(MyTime) ' MyMinute contains 35.
Second
Returns a Variant (Integer) specifying a whole number between 0 and 59, inclusive, representing the second of
the minute.
Syntax
Second(time)
The required time argument is any Variant, numeric expression, string expression, or any combination, that can
represent a time. If time contains Null, Null is returned.
Example:
Dim MyTime, MySecond
MyTime = #4:35:17 PM# ' Assign a time.
MySecond = Second(MyTime) ' MySecond contains 17.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


TimeSerial
Returns a Variant (Date) containing the time for a specific hour, minute, and second.
Syntax
TimeSerial(hour, minute, second)
The TimeSerial function syntax has these named arguments:
Part Description
hour Required; Variant (Integer). Number between 0 (12:00 A.M.) and 23 (11:00
P.M.), inclusive, or a numeric expression.
minute Required; Variant (Integer). Any numeric expression.
second Required; Variant (Integer). Any numeric expression.
Remarks
To specify a time, such as 11:59:59, the range of numbers for each TimeSerial argument should be in the
normal range for the unit; that is, 0–23 for hours and 0–59 for minutes and seconds. However, you can also
specify relative times for each argument using any numeric expression that represents some number of hours,
minutes, or seconds before or after a certain time. The following example uses expressions instead of absolute
time numbers.
Example:
Dim MyTime
MyTime = TimeSerial(16, 35, 17) ' MyTime contains serial
' representation of 4:35:17 PM.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


TimeValue
Returns a Variant (Date) containing the time.
Syntax
TimeValue(time)
The required time argument is normally a string expression representing a time from 0:00:00 (12:00:00 A.M.) to
23:59:59 (11:59:59 P.M.), inclusive. However, time can also be any expression that represents a time in that
range. If time contains Null, Null is returned.
Example:
Dim MyTime
MyTime = TimeValue("4:35:17 PM") ' Returns 4:35:17 PM


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


WeekDay
Returns a Variant (Integer) containing a whole number representing the day of the week.
Syntax
Weekday(date, [firstdayofweek])
The Weekday function syntax has these named arguments:
Part Description
date Required. Variant, numeric expression, string expression, or any combination, that
can represent a date. If date contains Null, Null is returned.
firstdayofweek Optional. A constant that specifies the first day of the week. If not specified,
vbSunday is assumed.
Settings
The firstdayofweek argument has these settings:
Constant Value Description
vbUseSystem 0 Use the NLS API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday
Return Values
The Weekday function can return any of these values:
Constant Value Description
vbSunday 1 Sunday
Aaron Wirth
49
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday
Example:
Dim MyDate, MyWeekDay
MyDate = #February 12, 1969# ' Assign a date.
MyWeekDay = Weekday(MyDate) ' MyWeekDay contains 4 because
' MyDate represents a Wednesday.