0 votes
1 view
in BI by (13.4k points)

I have a DateTime field .for e.g. 2013-08-22 12:00:00 AM. I want to concatenate the year and month and I want the output as 201308.

When i try year (datetime_field)+month(datetime_field) what i get get is 2013+08=2021 .. i.e it adds instead of concatenating. Can someone pl tell how to get the output as 201308?

1 Answer

+1 vote
by (36.7k points)
selected by
 
Best answer
  • Use the following line

str(year(datetime_field)) + str(month(datetime_field))

  • It gives what you want

  • The str function converts your numeric data to a string, setting up the + to be a string-concatenation operation instead of an arithmetic-addition operation.

...