Successfully!

Error!

Date and time function

  • Last update:  2023-11-20
  • DATE

    Description

    DATE(year, month, date)  

    Input

    year: a number that specifies the year. Type: integer.

     

    month: a number ranging from 1 to 12 that specifies the month. Type: integer.

     

    day: a number ranging from 1-31 that specifies one day in the month. Type: integer

    Output

    Output an date accroding to the specified year, month and day.

     

    Examples

    • DATE(1978, 9, 19) >> 1978-09-19

    • DATE(1211, 12, 1) >> 1211-12-01 

      DATEDELTA

      Description

      DATEDELTA(start_date, shift)  

      Input

      start_date: the initial point of the calculation. Type: date.

       

      shift: a number that specifies the days away from the start_date. Type: integer.

      Output

      Output a date which has a distance of shift away from start_date.

       

      Examples

      • DATEDELTA("2008-08-08", -10) >> 2008-07-29

      • DATEDELTA("2008-08-08", 10) >> 2008-08-18

        DATEDIF

        Description

        DATEDIF(start_date, end_date, unit)  

        Input

        start_date: the start date of the calculation. Type: date.

         

        end_date: the end date o the calculation. Type: date.

         

        dif_unit: the unit of the difference. The value can be "Y", "M" and "D" to represent year, month and day respectively.

        Output

        Output the difference between the start_date and end_date. The unit of difference can be year, month or day acoording to dif_unit. Type: integer.

         

        Examples

        • DATEDIF("2001/2/28","2004/3/20","Y") >> 3

        • DATEDIF("2001/2/28","2004/3/20","M") >> 37

        • DATEDIF("2001/2/28","2004/3/20","D") >> 1116

          DAY

          Description

          DATEDIF(date)  

          Input

          date: a date to be examined. Type: date.

          Output

          Output the day within the date. Type: integer

           

          Examples

          • DAY("2000/1/1") >> 1

          • DAY("2006/05/05") >> 5

          • DAY("2000-1-1") >> 1

          • DAY("2006-05-05") >> 5

            DAYSOFMONTH

            Description

            DATSOFMONTH(date)  

            Input

            date: a date to be examined. Type: date.

            Output

            Output the number of days within the month of that day. Type: integer.

             

            Examples

            • DAYSOFMONTH("1900-02-01") >> 28

            • DAYSOFMONTH("2008/04/04") >> 30

              DAYSOFQUARTER

              Description

              DATSOFQUARTER(date)  

              Input

              date: a date to be examined. Type: date.

              Output

              Output the number of days within the quarter of that day. Type: integer.

               

              Examples

              • DAYSOFQUARTER("2009-02-01") >> 90

              • DAYSOFQUARTER("2009/05/05") >> 91 

                DAYSOFYEAR

                Description

                DATSOFYEAR(value)

                Input

                value: a date or year that helps to position a specific year.

                Output

                Output the number of days within the specific year determined by value. Type: Integer.

                 

                Examples

                • DAYSOFYEAR("2008-01-01") >> 366

                • DAYSOFYEAR(2008) >> 366

                DATESUBDATE

                Description

                DATESUBDATE(date1, date2, op)

                Input

                date1: a date to be examined. Type: date.

                date2: a date to be examined. Type: date.

                op: time unit returned:

                "s",second;

                "m",minute;

                "h",hour;

                "d",day;

                "w",week.

                Output

                Output the number of the op units within the specific date determined by value. Type: Integer.


                Eamples

                • DATESUBDATE("2008-08-08", "2008-06-06","h") >> 1512

                HOUR

                Description

                HOUR(time)  

                Input

                time: the time to be examined. The format can be HH:mm:ss and YYYY-MM-DD HH:mm:ss. Type: date and time.

                Output

                Output the hour within the time. Type: integer.

                 

                Examples

                • HOUR("11:32:40") >> 1

                • HOUR("2019-01-01 11:32:40") >> 11

                  MINUTE

                  Description

                  MINUTE(time)  

                  Input

                  time: the time to be examined. The format can be HH:mm:ss and YYYY-MM-DD HH:mm:ss. Type: date and time.

                  Output

                  Output the hour within the time. Type: integer.

                   

                  Examples

                  • MINUTE("15:36:25") >> 36

                  • MINUTE("2019-01-01 15:36:25") >> 36

                    MONTH

                    Description

                    MONTH(date)  

                    Input

                    date: a date to be examined. Type: date.

                    Output

                    Output the month within the date. Type: integer

                     

                    Examples

                    • MONTH("2000/1/1") >> 1

                    • MONTH("1997/04/20") >> 4

                    • MONTH("2000-1-1") >> 1

                    • MONTH("1997-04-20") >> 4 

                      NOW

                      Description

                      NOW()  

                      Input

                      /

                      Output

                      Output current date and time. Type: datetime.

                       

                      Examples

                      • NOW() >> 2020-09-04 11:47:29

                      TIME

                      Description

                      TIME(hour, minute, second)  

                      Input

                      hour: a number ranging from 0 to 23 that specifies hour. Type: integer.

                       

                      minute: a number ranging from 0 to 59 that specifies minute. Type: integer.

                       

                      second: a number ranging from 0 to 59 that specifies second. Type: integer.

                      Output

                      Output date and time. The date is current day while the time is determined by hour, minute and second. Type: datetime.

                       

                      Examples

                      • TIME(14,40,0) >> 2020-09-04 14:40:00

                      • TIME(19,43,24) >> 2020-09-04 19:43:24 

                        TODAY

                        Description

                        TODAY()  

                        Input

                        /

                        Output

                        Output current date. Type: date.

                         

                        Examples

                        • TODAY() >> 2020-09-04

                        WEEK

                        Description

                        WEEK(serial_num): returns a number representing which week it is in a year. serial_num specifies the input date.

                        Function Logic

                        The first week of a year starts from the date corresponding to the first Sunday. In addition, a week starts from Sunday to Saturday.

                        week 图1.png

                        Dates are saved as serial numbers in FineReport. In this case, each serial number matches a date, facilitating users to perform numerical calculations on dates.

                        In the 1900 date system, 1900/1/1 is saved as serial number 2, and 1900/1/2 is saved as serial number 3 in FineReport. The rest can be deducted based on the similar principle. For example,1998/1/1 is saved as series number 35796.

                        Examples

                        • WEEK("2005/1/1") returns 52. (Dates before the first Sunday of the year are considered part of the last week      in the previous year.)

                        • WEEK("2005/1/6") returns 1. (The year starts from its first Sunday.)

                        • WEEK(35796) returns 52. (A series number matches a specific date, which then can be converted to the week      number).

                        Parameter Modification Logic

                        • WEEK(serial_num,"F1"): considers the date before the first Sunday of a year as its first week (using Excel's logic).

                        • WEEK(serial_num,"F7") or WEEK(serial_num): considers the data after the first Sunday of a year as its first week (using FineReport's default logic). In this case, the date before the first Sunday of the year is considered as the last week of the previous year.

                        Example:

                        • WEEK("2019/1/5","F1") returns 1.

                        • WEEK("2019/1/5","F7") returns 52.

                        • WEEK("2019/1/6","F1") returns 2.

                        • WEEK("2019/1/6","F7") returns 1.


                          WEEKDATE

                          Description

                           WEEKDATE(year, month, week_in_month, day_in_week)

                          Input

                          year: a number that specifies the year. Type: integer.

                           

                          month: a number ranging from 1 to 12 that specifies the month. Type: integer.

                           

                          week_in_month: a number that specifies the week in the month.Type: integer.

                           

                          day_in_week: a number that specifies the day in the week. Type: integer.

                          Output

                          Output the date according to the input year, month week and day. Type: date.

                           

                          Examples

                          • WEEKDATE(2009,10,2,1) >> 2009-10-04

                          • WEEKDATE(2009,12,1,-1) >> 2009-12-05

                            WEEKDAY

                            Description

                            WEEKDAY(date)  

                            Input

                            date: a date to be examined. Type: date.

                            Output

                            Output a number that represents the day of the week of the input date. Type: integer.

                             

                            Examples

                            • WEEKDAY("2005/9/10") >> 6 (i.e. saturday)

                            • WEEKDAY("2005/9/11") >> 0 (i.e. sunday)

                              YEAR

                              Description

                              YEAR(date)  

                              Input

                              date: a date to be examined. Type: date.

                              Output

                              Output the year within the date. Type: integer

                               

                              Examples

                              • YEAR("2000/1/1") >> 2000

                              • YEAR("2006/05/05") >> 2006

                              • YEAR("2000-1-1") >> 2000

                              • YEAR("2006-05-05") >>2006

                              Date.cpt


                              Attachment List


                              Theme: Report Features
                              Already the First
                              Already the Last
                              • Helpful
                              • Not helpful
                              • Only read

                              Doc Feedback