Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Adding millisecond to date in SAP HANA

I have written a SP that saves current timestamp in a variable. In SAP HANA, following functions are there to add an amount of time to a date:

  • ADD_YEARS
  • ADD_MONTHS
  • ADD_DAYS
  • ADD_WORKDAYS
  • ADD_SECONDS

If I have to add amount of ms to a date so if there is a way to achieve this?


1 Answer
Anil SAP Gupta

Try using ADD_SECONDS function as below:

SELECT ADD_SECONDS (TO_TIMESTAMP('2017-07-15 02:17:15'), 0.1) FROM TEST

This will add seconds as fraction value as requested. Below is syntax and example:

ADD_SECONDS

Syntax

ADD_SECONDS (t, n)

Description

Computes the time t plus n seconds.

Example:

SELECT ADD_SECONDS (TO_TIMESTAMP ('2012-01-01 23:30:45'), 60*30) "add seconds" FROM DUMMY;

add seconds

2012-01-02 00:00:45.0

To know more about ADD_SECONDS function, you can also refer this link:

datetime function in SAP HANA

To know more about SQL functions in SAP HANA system, you can also refer our HANA tutorial:

SAP HANA SQL Functions



Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.