$Date: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
m (minor cleanup)
 
Line 1: Line 1:
<p>The $Date function returns an 8- or 10-character string equal to the current date in yy-mm-dd format (for example, 90-09-20) or yyyy-mm-dd format (for example, 1990-09-20). The default is 8 characters. If $Date is stored as a field value, you can use this form to sort records chronologically. </p>
<p>
<b>Usage</b>
The <var>$Date</var> function returns an 8- or 10-character string equal to the current date in YY-MM-DD format (for example, 90-09-20) or YYYY-MM-DD format (for example, 1990-09-20). The default is 8 characters. If <var>$Date</var> is stored as a field value, you can use this form to sort records chronologically. </p>
<p>When using $Date in field values, make sure that all values of $Date are in the same format. You will get incorrect results when sorting records if you mix yyyy and yy formats.       </p>
 
<b>Syntax</b>
==Usage==
<p>The format for $Date is:</p>
<p>
<p class="code">$Date(year-format,fill-character)
When using <var>$Date</var> in field values, make sure that all values of <var>$Date</var> are in the same format. You get incorrect results when sorting records if you mix YYYY and YY formats. </p>
 
==Syntax==
<p>
The format for <var>$Date</var> is:</p>
<p class="syntax">$Date(<span class="term">year-format</span>, <span class="term">fill-character</span>)
</p>
</p>
<p>See [[Overview of $Date functions#Overview of $Date functions|Overview of $Date functions]] for syntax details.</p>
<p>
<p>If <var class="product">Model&nbsp;204</var> encounters an error, the function returns all asterisks (*).</p>
See [[Overview of $Date functions#Overview of $Date functions|Overview of $Date functions]] for syntax details.</p>
<b>Example</b>
<p>
<p>The following request prompts a user for data values and automatically stores the current date with each new record (using the 8-character format).</p>
If <var class="product">Model&nbsp;204</var> encounters an error, the function returns all asterisks (<tt>*</tt>).</p>
<p class="code">BEGIN
 
%DATE = $date
==Example==
GET.FIRST: %A = $READ('ENTER FIELD A')
<p>
           %B = $READ 'ENTER FIELD B')
The following request prompts a user for data values and automatically stores the current date with each new record (using the 8-character format).</p>
<p class="code">Begin
%date = $date
GET.FIRST: %a = $READ('ENTER FIELD A')
           %b = $READ 'ENTER FIELD B')
           STORE RECORD
           STORE RECORD
               FLD A = %A
               FLD A = %a
               FLD B = %B
               FLD B = %b
                 .
                 .
                 .
                 .
                 .
                 .
               DATE STORED = %DATE
               DATE STORED = %date
           END STORE
           END STORE
           IF $READ('NEXT RECORD: Y OR CR') EQ -
           IF $READ('NEXT RECORD: Y OR CR') EQ -
               'Y' THEN JUMP TO GET.FIRST
               'Y' THEN JUMP TO GET.FIRST
           END IF
           END IF
END  
End  
</p>
</p>
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Latest revision as of 21:00, 6 October 2015

The $Date function returns an 8- or 10-character string equal to the current date in YY-MM-DD format (for example, 90-09-20) or YYYY-MM-DD format (for example, 1990-09-20). The default is 8 characters. If $Date is stored as a field value, you can use this form to sort records chronologically.

Usage

When using $Date in field values, make sure that all values of $Date are in the same format. You get incorrect results when sorting records if you mix YYYY and YY formats.

Syntax

The format for $Date is:

$Date(year-format, fill-character)

See Overview of $Date functions for syntax details.

If Model 204 encounters an error, the function returns all asterisks (*).

Example

The following request prompts a user for data values and automatically stores the current date with each new record (using the 8-character format).

Begin %date = $date GET.FIRST: %a = $READ('ENTER FIELD A') %b = $READ 'ENTER FIELD B') STORE RECORD FLD A = %a FLD B = %b . . . DATE STORED = %date END STORE IF $READ('NEXT RECORD: Y OR CR') EQ - 'Y' THEN JUMP TO GET.FIRST END IF End