Year: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
JwellsNB (talk | contribs)
Added javascript snippet
Line 5: Line 5:
Year returns an integer, that represents the year of the given date.The required parameter, ''date'', can be any expression that represents a date.
Year returns an integer, that represents the year of the given date.The required parameter, ''date'', can be any expression that represents a date.


== Example ==
== Example (Basic) ==


<pre>
<pre>
Rem Year Example
Rem Year Example
'Year returns year of a date as an integer
'Year returns year of a date as an integer
Dim IndepYear, Birthyear
Dim IndepYear, Birthyear
IndepYear = Year("July 4, 1776")
IndepYear = Year("July 4, 1776")
Line 16: Line 17:
Print "YEAR of 12/27/70:", Birthyear
Print "YEAR of 12/27/70:", Birthyear
</pre>
</pre>
== Example (JavaScript) ==
// Year Example
/* Year returns year of a date as an integer */
var  IndepYear, Birthyear;
IndepYear = new Date("July 4, 1776").getFullYear();
document.write(("YEAR of July 4, 1776:" + " " + IndepYear) + "<br>");
Birthyear = new Date("12/27/70").getFullYear();
document.write(("YEAR of 12/27/70:" + " " + Birthyear) + "<br>");


== Output ==
== Output ==


<pre>
<pre>
Year of July 4, 1776:     1776
YEAR of July 4, 1776: 1776
Year of 12/27/70:   1970
YEAR of 12/27/70: 1970
</pre>
</pre>



Revision as of 03:47, 12 May 2013

Year(date)

Description

Year returns an integer, that represents the year of the given date.The required parameter, date, can be any expression that represents a date.

Example (Basic)

Rem Year Example
'Year returns year of a date as an integer

Dim IndepYear, Birthyear
IndepYear = Year("July 4, 1776")
Print "YEAR of July 4, 1776:", IndepYear
Birthyear = Year("12/27/70")
Print "YEAR of 12/27/70:", Birthyear

Example (JavaScript)

// Year Example /* Year returns year of a date as an integer */

var IndepYear, Birthyear; IndepYear = new Date("July 4, 1776").getFullYear(); document.write(("YEAR of July 4, 1776:" + " " + IndepYear) + "
"); Birthyear = new Date("12/27/70").getFullYear(); document.write(("YEAR of 12/27/70:" + " " + Birthyear) + "
");

Output

YEAR of July 4, 1776: 1776
YEAR of 12/27/70: 1970

Related Items

Day, Hour, Minute, Month, Now, Second, Time