The Code is as follows:
'Change time
Private sub cbtnchangetime_click ()
Dim sdate as string
Dim stime as string
Dim adate as date
Sdate = system. currentdate 'iFIX provides
Stime = system. currenttime' iFIX provides
Adate = dateadd ("YYYY",-1, sdate) 'year minus 1
Sdate = format (adate, "YYYY-M-D ")
Textdatec. Caption = sdate
Texttimec. Caption = stime
End sub
Reference:
Dateadd Function
ReturnsVariant(Date), This date also adds a period of time interval.
Syntax
Dateadd (Interval, number, date)
DateaddThe function syntax includes the following naming parameters:
Part |
Description |
Interval |
Required. String expression, which is the time interval to be added. |
Number |
Required. A numeric expression is the number of time intervals to be added. The value can be a positive number (to get the future date) or a negative number (to get the past date ). |
Date |
Required.Variant(Date) Or indicates the text of the date, which is also added with the time interval. |
Set
IntervalParameters have the following settings:
Set |
Description |
Yyyy |
Year |
Q |
Quarter |
M |
Month |
Y |
Number of days per year |
D |
Day |
W |
Number of days in a week |
WW |
Week |
H |
Hour |
N |
Minutes |
S |
Seconds |
Description
AvailableDateaddThe function adds or subtracted the specified time interval to the date. For example, you can useDateaddTo calculate the date of thirty days from the past day, or 45 minutes from now.
ToDateWith "day", you can use "day of the year" ("Y"), "day" ("D"), or "day of the week" ("W ").
DateaddThe function does not return a valid date. Add April 1 to the previous month in the following instances:
DateAdd(m, 1, 31-Jan-95)
In the above example,DateaddReturns February 28, 1995 instead of February 31, 1995. If
DateThis is July January 31, 1996, because July 1996 is a leap year, and the returned value is July February 29, 1996.
If the calculation date is later than 100 (minus the year exceedingDateThe year in.
IfNumberIf it is not a long value, the nearest integer is used for calculation.
Note dateaddThe format of the return value isControl PanelThe settings are determined, rather than being passedDateThe format of the parameter is determined.