Hide Table of Contents

Functions for Variables

In creating variables, use string and arithmetic functions to configure their values. You can add these functions by clicking right arrow next to Value fields in dialog boxes.

String Functions

Function

Left

Description

Returns the leftmost specified number of characters from a specified string.

Syntax

Left(<string>,<number>)

Arguments

<string> - The character string

<number> - The number of characters to be returned

Example

Left(ProjectAA,7)

Returns "Project"

Function

Right

Description

Returns the rightmost specified number of characters from a specified string.

Syntax

Right(<string>,<number>)

Arguments

<string> - The character string

<number> - The number of characters to be returned

Example

Right(ProjectAA,2)

Returns "AA"

Function

Mid

Description

Returns a substring from a specified string (starting at a specified position).

Syntax

Mid(<string>,<startpos>,<number>)

Arguments

<string> - The character string

<startpos> - The number of the starting position. The first character is position 0.

<number> - The number of characters to be returned

Example

Mid(ProjectAA,2,2)

Returns "je"

Function

Length

Description

Returns the length of a specified string.

Syntax

Length(<string>)

Arguments

<string> - The character string

Example

Length(ProjectAA)

Returns 9

Function

Reverse

Description

Returns the reverse of a specified string.

Syntax

Reverse(<string>)

Arguments

<string> - The character string

Example

Reverse(stockholm)

Returns "mlohkcots"

Function

Find

Description

Searches a specified string for the first match of a character or substring. Returns the position where the character or substring is found.

The first position in the character string is 0.

Syntax

Find(<string>,<substring>)

Arguments

<string> - The character string

<substring> - The character substring for which to search

Example

Find(abc,b)

Returns 1

Function

ReverseFind

Description

Searches a specified string for the last match of a character. Returns the position where the last occurrence of the character or substring is found.

The first position in the character string is 0.

Syntax

Find(<string>,<substring>)

Arguments

<string> - The character string

<substring> - The character substring for which to search

Example

ReverseFind(abcabc,b)

Returns 4

Function

CurrentTime

Description

Returns the current date or time in a specified format

Syntax

CurrentTime(%%Y-%%m-%%d %%H:%%M:%%S)

Arguments

%%a - Abbreviated weekday name

%%A - Full weekday name

%%b - Abbreviated month name

%%B - Full month name

%%c - Date and time representation appropriate for locale

%%d - Day of month as decimal number (01 - 31)

%%H - Hour in 24-hour format (00 - 23)

%%I - Hour in 12-hour format (01 - 12)

%%j - Day of year as decimal number (001 - 366)

%%m - Month as decimal number (01 - 12)

%%M - Minutes as decimal number (00 - 59)

%%p - Current locale's A.M./P.M. indicator for 12-hour clock

%%S - Seconds as decimal number (00 - 59)

%%U - Week of year as decimal number, with Sunday as first day of week (00 - 53)

%%w - Weekday as decimal number (0 - 6; Sunday is 0)

%%W - Week of year as decimal number, with Monday as first day of week (00 - 53)

%%x - Date representation for current locale

%%X - Time representation for current locale

%%y - Year without century, as decimal number (00 - 99)

%%Y - Year with century, as decimal number

%%z,%%Z - Either the time zone name or abbreviation, depending on registry settings; no characters if time zone is unknown

%%%% - Percent sign

Examples

CurrentTime(%%y%%m%%d)

Returns "050113"

CurrentTime (%%H:%%M)

Returns "09:53"

Arithmetic Functions

Function

Add

Description

Returns the sum of the two specified numbers.

Syntax

Add(<term1>,<term2>)

Arguments

<term1> - First term

<term2> - Second term

Example

Add(2,3)

Returns 5

Function

Sub

Description

Returns the difference between the two specified numbers.

Syntax

Sub(<term1>,<term2>)

Arguments

<term1> - First term

<term2> - Second term (amount to be subtracted)

Example

Sub(3,2)

Returns 1



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Functions for Variables
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: SOLIDWORKS PDM 2016 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.