CURRENT

CURRENT operator reads the system clock and returns the current date and time of day as a DATETIME value of a specified or default precision.

CURRENT operator supports all DATETIME qualifiers:

So, you can specify the necessary precision of the returned value in this way:

CURRENT first TO last

For example,

DISPLAY CURRENT YEAR TO MINUTE

By default (= no qualifier is specified), the precision is YEAR TO FRACTION(3).

 

When you specify the precision for the returned value, its first keyword must specify a time unit that is the same as or larger than the time unit of the last keyword.

For example, this qualifier is valid:

CURRENT YEAR TO MONTH

But this qualifier is not valid because the month is smaller than year:

CURRENT MONTH TO YEAR

If FRACTION is the second part of the qualifier, you can specify how many digits (from 1 to 5) will be included in the seconds value.

For example, for January 1, 2001, CURRENT YEAR TO FRACTION(5) will return 2001-01-01 14:19:56.07293.

If CURRENT is executed more than once in a statement, identical values might be returned at each call.

However, the order in which the CURRENT operator is executed in a statement cannot be predicted. For this reason, do not attempt to use this operator to mark the start or end of a 4gl statement or any specific point in the execution of a statement.

You can use the CURRENT operator both in 4gl and SQL statements.

This is an example of an SQL statement:

SELECT * FROM activity

  WHERE open_date = CURRENT YEAR TO DAY

This is an example from a .per form:

ATTRIBUTES -- 4gl field

timestamp = FORMONLY.tmstmp TYPE DATETIME HOUR TO SECOND,

DEFAULT = CURRENT HOUR TO SECOND;

This is an example from a classic 4gl report:

PAGE HEADER

PRINT COLUMN 40, CURRENT MONTH TO MONTH,

      COLUMN 42, "/",

      COLUMN 43, CURRENT DAY TO DAY,

      COLUMN 45, "/",

      COLUMN 46, CURRENT YEAR TO YEAR

CURRENT will not return correct results if its execution spanned the midnight.

 

Here is an example of how the CURRENT operator is used:

MAIN

  DEFINE

    mydate DATE,

    d_yyff DATETIME YEAR TO FRACTION(5),

    d_yymo DATETIME YEAR TO MONTH,

    d_modd DATETIME MONTH TO DAY,

    d_momi DATETIME MONTH TO MINUTE,

    d_ddhh DATETIME DAY TO HOUR,

    d_ddss DATETIME DAY TO SECOND,

    d_hhmm DATETIME HOUR TO MINUTE,

    d_hhss DATETIME HOUR TO SECOND,

    d_mmff DATETIME MINUTE TO FRACTION

 

  LET mydate = CURRENT

  LET d_yyff = CURRENT YEAR TO FRACTION(5)

  LET d_yymo = CURRENT YEAR TO MONTH

  LET d_modd = CURRENT MONTH TO DAY

  LET d_momi = CURRENT MONTH TO MINUTE

  LET d_ddhh = CURRENT DAY TO HOUR

  LET d_ddss = CURRENT DAY TO SECOND

  LET d_hhmm = CURRENT HOUR TO MINUTE

  LET d_hhss = CURRENT HOUR TO SECOND

  LET d_mmff = CURRENT MINUTE TO FRACTION

 

  DISPLAY "LET mydate = CURRENT" AT 3,3

  DISPLAY mydate AT 3,50

 

  DISPLAY "LET d_yyff = CURRENT YEAR TO FRACTION(5)" AT 4,3

  DISPLAY d_yyff AT 4,50

 

  DISPLAY "LET d_yymo = CURRENT YEAR TO MONTH" AT 5,3

  DISPLAY d_yymo AT 5,50

 

  DISPLAY "LET d_modd = CURRENT MONTH TO DAY" AT 6,3

  DISPLAY d_modd AT 6,50

 

  DISPLAY "LET d_momi = CURRENT MONTH TO MINUTE" AT 7,3

  DISPLAY d_momi AT 7,50

 

  DISPLAY "LET d_ddhh = CURRENT DAY TO HOUR" AT 8,3

  DISPLAY d_ddhh AT 8,50

 

  DISPLAY "LET d_ddss = CURRENT DAY TO SECOND" AT 9,3

  DISPLAY d_ddss AT 9,50

 

  DISPLAY "LET d_hhmm = CURRENT HOUR TO MINUTE" AT 10,3

  DISPLAY d_hhmm AT 10,50

 

  DISPLAY "LET d_hhss = CURRENT HOUR TO SECOND" AT 11,3

  DISPLAY d_hhss AT 11,50

 

  DISPLAY "LET d_mmff = CURRENT MINUTE TO FRACTION" AT 12,3

  DISPLAY d_mmff AT 12,50

 

  CALL fgl_getkey()

END MAIN

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.