Date increase/decrease in vbs in iFIX

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.