Home > Software engineering >  Design time flies form (about date code)
Design time flies form (about date code)

Time:09-24

CodePudding user response:

Good good study, earnestly, to solve the problem.

CodePudding user response:


DateSerial function


Returns a specified year, month, day of the Variant (Date),

Syntax

DateSerial (year, month, day)

DateSerial function grammar the naming of any of the following parameters:

Part of the description
Year necessary; Integer, from 100 to 9999 between Integer, or a numerical expression,
The month necessary; Integer, any numerical expression,
Day necessary; Integer, any numerical expression,


Description

To specify a date, such as on December 31, 1991, DateSerial function of each parameter value scope should be acceptable; , namely, the scope should be between 1 and 31, and the scope of the month shall be between 1 and 12, however, when a numerical expression said one day before or after years, months, days, can also use this numerical expression for each parameter specifies the relative date,

In the following example USES a numerical expression instead of absolute date, here, DateSerial function returns on August 1, 1990, 10 years (1990-10) and two months (8-2) and (1, 1) before a day of date; In other words, on May 31, 1980,

DateSerial (2, 1990-10, 8-1-1)

Year if parameter values between 0 and 29, will interpret it as 2000-2029, if between 30 and 99 between the explanation for the 1930-1999, and of all other year parameters, then please use four numeric representation (e.g., 1800),

When any one parameter was beyond the range of acceptable values, it will timely carry on to the next larger unit of time, for example, if you specify the 35 days, then the number of days was interpreted as the days of a month plus extra, extra days will be determined by the month and year, if a parameter value beyond the range of 32768 to 32767, will lead to errors,
DateSerial function example
This example USES DateSerial function to convert the specified Date to the Date type of expression,

Dim MyDate
'MyDate value of 9 February 12196, the Date type,
MyDate=DateSerial (1969, 2, 12) 'return date,

  •  Tags:  
  • VBA
  • Related