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 - dtos() convert a date to a field date string http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 dtos()              Convert a date to a field date string
------------------------------------------------------------------------------
 Declaration
   date.hdr

 Syntax
   func char(8) dtos extern
   param value date dDate

 Arguments
   dDate is a date value.

 Return
   A field date string corresponding to the passed date.

 Description
   The dtos() function converts the date value passed with the dDate
   parameter into a string. The result has the YYYYMMDD format, i.e. the four-
   digit year is followed by the two-digit month and the two-digit day.
   The output format corresponds to the internal representation of date
   fields in databases. The function always returns this format, independent
   of the current status of set date.

 Example
   #define EXAMPLE_DATE
   #include example.hdr

   // Use of the dtos() function to define an index key which provides
   // a date-time order
   
   dbfdef sAccidents
      date     AccDate
      char(8)  AccTime
      char(25) City
      char(30) Street
      char(70) Descript
   enddef
   
   indexdef
      char(16) xWhen dtos( sAccidents->AccDate ) + sAccidents->AccTime
   enddef
   
   proc Test_dtos
   vardef
      int n
   enddef
   build "acc.dbf" from alias sAccidents                  // make database
   open "acc.dbf" from alias sAccidents
   for n := 1 to 10                                       // fill database
      append blank
      sAccidents->AccDate := daysfrom( today(), n - 10 )
      sAccidents->AccTime := time()
   next
   index "acc.fdx" alias xWhen                            // make index
   set index to xWhen
   seek dtos( today() ) + time()                          // use index
   ? "Record", iifc( found(), "found", "not found" )      // show result
   close sAccidents
   erase "acc.dbf"                                        // clean up
   erase "acc.fdx"
   endproc

   proc main
   Test_dtos()
   endproc

See Also: dtoc() fdtoc()

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