Moves one field to another field and optionally edits the field.
Specifies any source column, variable, or literal.
A date can be stored in a date variable or column, or a string literal, column, or variable. When using a date format_mask or the keyword DATE with MOVE, the source, if a string literal, column, or variable, must be in the format specified by SQR_DB_DATE_FORMAT, one of the database-dependent formats in Table 61, Default Formats by Database, or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.
When numerical precision is important, use LET. When no edit mask is specified, MOVE uses the 6 digit precision default mask.
Optional format mask. (see Edit Masks)
Formats src_any_lit|_var|_col with the NUMBER‑EDIT-MASK from the current locale. Not legal with date variables. (see Edit Masks)
Formats src_any_lit|_var|_col with the MONEY‑EDIT-MASK from the current locale. Not legal with date variables. (see Edit Masks)
Formats src_any_lit|_var|_col with the DATE‑EDIT‑MASK from the current locale. Not legal with numeric variables. (see Edit Masks)
Moves the source field to the destination field. Optionally, you can reformat the field using the format_mask argument. Source and destination fields can be different types, numeric, text, or date. MOVE is also useful for converting from one type to another; however, date and numeric variables are incompatible.
When a date variable or column is moved to a string variable, the date is converted according to the following rules:
For DATETIME columns and Production Reporting DATE variables, Production Reporting uses the format specified by SQR_DB_DATE_FORMAT. If not set, Production Reporting uses the first database-dependent format in Table 61, Default Formats by Database.
For DATE columns, Production Reporting uses the format specified by SQR_DB_DATE_ONLY_FORMAT. If not set, Production Reporting uses the format in Table 62, DATE Column Formats.
For TIME columns, Production Reporting uses the format specified by SQR_DB_TIME_ONLY_FORMAT. If not set, Production Reporting uses the format in Table 63, TIME Column Formats.
Finally, as this example shows, the edit mask can be contained in a string variable.
This example illustrates the various features of MOVE:
! ! Convert a string in place ! move '123456789' to $ssn move $ssn to $ssn xxx-xx-xxxx show '$SSN = ' $ssn
Produces the following output:
$SSN = 123-45-6789
! ! Convert a number to a string using an edit mask ! move 1234567.89 to #value move #value to $value 999,999,999.99 show '$Value = ' $value
Produces the following output:
$Value = 1,234,567.89
! ! Convert a number to a string using a variable edit mask ! move 123 to #counter move '099999' to $mask move #counter to $counter :$mask show '$Counter = ' $counter
Produces the following output:
$Counter = 000123
! ! Convert a number to a string using the default edit mask ! ! Production Reporting, by default, ouputs six digits of precision. ! If you require more or less precision, specify an edit mask. ! move 123.78 to #defvar move #defvar to $defvar show '$DefVar = ' $defvar
Produces the following output:
$DefVar = 123.780000
! ! Convert the number to a string using the locale default ! numeric edit mask ! alter-locale number-edit-mask = '99,999,999.99' move 123456.78 to #nvar move #nvar to $nvar number show '$NVar = ' $nvar
Produces the following output:
$NVar = 123,456.78
! ! Convert the money value to a string using the locale default ! money edit mask ! alter-locale money-edit-mask = '$9,999,999.99' move 123456.78 to #mvar move #mvar to $mvar money show '$MVar = ' $mvar
Produces the following output:
$MVar = $ 123,456.78
! ! Convert the date column to a string using the locale default ! date edit mask ! begin-select dcol from tables end-select alter-locale date-edit-mask = 'Mon-DD-YYYY' move &dcol to $dvar date show '$DVar = ' $dvar
Produces the following output:
$DVar = Jan-01-1999
! ! Reset date to first day of the month ! ($date1 and $date2 have been defined as date variables) ! let $date1 = datenow() move $date1 to $date2 'MMYYYY' show '$Date2 = ' $date2 edit 'MM/DD/YY HH:MI'
Produces the following output if the report was run in October of 1995.
$Date2 = 10/01/95 00:00
! ! Convert date to a string ! ($date1 has been defined as a date variable) ! move $date1 to $str_date 'DD-MON-YYYY' show '$Str_Date = ' $str_date
Produces the following output.
$Str_Date = 01-DEC-1995
! ! Convert string (in partial format of SYYYYMMDDHHMISSNNN) to a ! date ! move '19951129' to $date1 show '$Date1 = ' $date1 edit 'Mon DD YYYY HH:MI'
Produces the following output.
$Date1 = Nov 29 1995 00:00
LET for information on copying, editing, or converting fields
The EDIT parameter of PRINT for edit mask descriptions
ALTER-LOCALE for descriptions of NUMBER-EDIT-MASK, MONEY‑EDIT-MASK, and DATE-EDIT-MASK
PRINT for the default date-time components as a result of moving an incomplete date to a date variable