反馈已提交

网络繁忙

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

    Attachment List


    Theme: データの追加および編集
    前の記事
    次の記事
    • いいね
    • 良くない
    • 閲覧しただけ

    フィードバック

    鼠标选中内容,快速反馈问题

    鼠标选中存在疑惑的内容,即可快速反馈问题,我们将会跟进处理。

    不再提示

    10s后关闭