Thursday, May 5, 2011

Data Types more (date, time)


Date variables are stored as IEEE 64-bit (8-byte) floating-point numbers that represent dates ranging from 1 January 100 to 31 December 9999 and times from 0:00:00 to 23:59:59. Any recognizable literal date values can be assigned to Date variables. Date literals must be enclosed within number signs (#), for example, #January 1, 1993# or #1 Jan 93#.
Date variables display dates according to the short date format recognized by your computer. Times display according to the time format (either 12-hour or 24-hour) recognized by your computer.

When other numeric types are converted to Date, values to the left of the decimal represent date information while values to the right of the decimal represent time. Midnight is 0 and midday is 0.5. Negative whole numbers represent dates before 30 December 1899.







             Dim thedate As Date
             thedate = Date
             Res = MsgBox(Date, vbOKOnly, "Date Demo")




             Dim thedate As Date
             thedate = Time    



Res = MsgBox(Time, vbOKOnly, "Date Demo")

Dim thedate As Date
thedate = Date & Time
Res = MsgBox(thedate, vbOKOnly, "Date Demo")

Dim thedate1, thedate2 As Date
thedate1 = Day(Date)

Res = MsgBox(thedate1, vbOKOnly, "Date Demo")





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:

Return Values
The Weekday function can return any of these values:

.
Constant
Value
Description
vbSunday
1
Sunday
vbMonday
2
Monday
vbTuesday
3
Tuesday
vbWednesday
4
Wednesday
vbThursday
5
Thursday
vbFriday
6
Friday
vbSaturday
7
Saturday

.

No comments:

Post a Comment