Calculating the Time Field N Hours/Minutes/Seconds after a Specified Time

  • Last update:  2023-09-28
  • Overview

    Requirement Description

    Date functions are widely used in work and life, and so are the adding or subtracting of specified time intervals in time fields.

    For applications of date functions provided by FineBI, see Overview of Date Functions.

    This document introduces how to calculate the time field N hours/minutes/seconds after a specified time.

    Implementation Method

    Use the TODATE and DATETONUMBER functions in combination.

    Example

    Adding Columns

    Create an analysis subject and add any dataset. Add a Formula Column and enter the formula NOW() to get the current time.

    1.png

    To calculate the time two hours, two minutes, and two seconds after the Current Time field, you can add formula columns and enter the following formulas respectively.




    TODATE(DATETONUMBER(Current Time)+2*3600*1000)

    Calculates the time two hours after the current time.

    TODATE(DATETONUMBER(Current Time)+2*60*1000)

    Calculates the time two minutes after the current time.

    TODATE(DATETONUMBER(Current Time)+2*1000)

    Calculates the time two seconds after the current time.

    2.png



    iconNote:
    The Current Time field needs to be selected from the left column and cannot be entered manually.


    The following table explains each formula in detail.

    Number

    Formula

    Explanation

    1

    TODATE(DATETONUMBER(Current Time)+N*3600*1000)

    Converts the Current Time to milliseconds, adds the millisecond form the time interval (N hours * 3600 seconds per hour * 1000   milliseconds per second), and converts the result to a standard date value with the TODATE function.

    2

    TODATE(DATETONUMBER(Current Time)+N*60*1000)

    Converts the Current Time to milliseconds, adds the millisecond form the time interval (N hours * 60 seconds per minute * 1000 milliseconds per second), and converts the result to a standard date value with the TODATE function.

    3

    TODATE(DATETONUMBER(Current Time)+N*1000)

    Converts the Current Time to milliseconds, adds the millisecond form the time interval (N hours * 1000 milliseconds per second), and converts the result to a standard date value with the TODATE function.

    Demonstration

    Click Save All and Update. The result is shown in the following figure.

     3.png

    附件列表


    主题: Adding and Editing Data
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy