cancel
Showing results for 
Search instead for 
Did you mean: 

Date truncate function?

Former Member
0 Kudos

So I have a fact table that has a date field (datatype: TIMESTAMP and it looks like this 2012-09-03 01:00:00.0. I want to create a calculated column where i truncate the timestamp portion of this.I defined a function like this: TRUNC("PROMISE_DATE",'YYYY')

But when trying to validate, get an error like this:

    • testpkg.TEST_AV2: ABAP name validity successful
  • Server side validation
    • Activation Id:278
      • Repository: Activation failed for at least one object;At least one runtime reported an error during activation. Please see CheckResults for details
        • Activation is performed with activation mode Cascade one-phase.
        • Internal deployment of object failed;Repository               :                Encountered an error in repository runtime extension;Internal Error:Create Scenario: failed aCalcEngine.createScenario(): The following errors occured: Inconsistent calculation model (34011)nDetails (Errors):n- CalculationNode (finalAggregation) ->
          attributes ->
          calculatedAttribute (PROMISE_DATE_TRUNC) ->
          expression: Attribute 'trunc' is missing in node finalAggregation.nnnprinting XML <?xml version="1.0" encoding="utf-8"?>
          <cubeSchema version="3" operation="createCalculationScenario">
          <calculationScenario name="testpkg/TEST_AV2" schema="_SYS_BIC">
          <dataSources>
          <olapDataSource name="dataSource" schema="_SYS_BIC" view="testpkg/TEST_AV2/olap">

Accepted Solutions (0)

Answers (4)

Answers (4)

0 Kudos

date(component("DATE", 1), component("DATE", 2), component("DATE", 3))

Ravi_Channe
Active Contributor
0 Kudos

Hi Sudarshan,

Somehow my reply from yesterday is not being shown.

Can you please try using leftstr(string(<date>, 4)) to get the year information.

Regards,

Ravi

former_member182114
Active Contributor
0 Kudos

Hi Ravi,

Cross post:

http://scn.sap.com/message/13904960

Regards, Fernando Da Rós

rama_shankar3
Active Contributor
0 Kudos

Sudharshan,

What is your requirement? Please explain your requirement so that I guide you better.

If you trying to do date logic something like below. Use as reference the below syntax without stripping the time value.

daysbetween (ADATE - now()) / daysbetween(BDATE - CDATE))

Hope this helps.

Former Member
0 Kudos

Hi Sudarshan,

Please reference the development guide from help.sap.com/hana_appliance

In section 7.5.11 you'll find all the functions that can be used in such expressions - trunc is not among them.

You should be able to convert the timestamp to date directly using the date() function.

Cheers,

Jody