4 Replies Latest reply: Jan 25, 2012 12:55 PM by Rajinder Dhillon RSS

    Concatenate date & num issue

      Hello folks, Can anyone enlighten me as to why the following is happening? And a possible solution / workaround?
      I wish to concatenate two tables based on Year field.
      Year does not exist in tableA only date column ("date" format when right click in Excel, DD/MM/YYYY, e.g 01/01/2011)
      TableB "general" format when right click in Excel. (e.g 2011)
      When I perform the following script I receive strange results?
      date (SalesTblShipDate,'YYYY') as ShipYearIDKey
      resident Sales;
      Concatenate (TableNamexxx)
      TargetsTblYear as ShipYearIDKey
      resident targets;
      The results
      The targets table is showing 2011. But when I perform the above action, Year from my second table (targets) is coming through at 1905??
      Any clues why this is happening?
      Many thanks in advance
        • Concatenate date & num issue
          Stefan Wühl

          Your year 2011 of the second table is interpreted as Date type's numerical representation, 2011 is the representation of 1905, July 3rd.


          Try using

          year(SalesTblShipDate) as ShipYearIDKey,


          in your first load.

            • Concatenate date & num issue

              Thank you swuehl.


              We had thought that was the cause but hadn't thought to use the year function.


              We do have pretty much the same issue with trying to extract month number from first load from date field.  Second table has month as single digit for months 1 to 9.  I've looked on help files and have only come around month(date) function but that only gives you returns a text string representing the month.  We getting similar incorrect error as we were getting on year.  So same issue.


              What would suggest for similar case with month number?  Colleague was thinking using MID with ROUND combination?  Not tried mind you, just an idea.