Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - year() return the year of a date http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 year()              Return the year of a date
------------------------------------------------------------------------------
 Declaration
   date.hdr

 Syntax
   func int year extern
   param value date dDate

 Arguments
   dDate is the date value to convert.

 Return
   The year of the specified date value including the century digits as a
   four-digit numeric value.

 Description
   The year() function converts dDateValue to an integer representing the
   year. The value returned is not affected by the current set date or
   set century setting.

 Example
   #define EXAMPLE_DATE
   #include example.hdr

   // Calculate the age of an employee.
   
   func int age
   param value date dStart
   vardef
      uint nAge
   enddef
   nAge := year( today() ) - year( dStart )
   if month( today() ) > month( dStart )
      return( nAge )
   endif
   if month( today() ) < month( dStart )
      nAge--
   else
      if day( today() ) < day( dStart )
         nAge--
      endif
   endif
   return( nAge )
   endpro
   
   proc Test_year
   vardef
      date dBirth
   enddef
   ? year( today() )         // print the current year
   input "When were you born (mm/dd/yy)? " to dBirth
   ? "Your age is", istr( Age( dBirth ) ), "years"
   endproc

   proc main
   Test_year()
   endproc

See Also: day() month()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson