4

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 conactenating. Can someone pl tell how to get the output as 201308?

Mansfield
  • 14,445
  • 18
  • 76
  • 112
Gautam Seshadri
  • 155
  • 2
  • 3
  • 10

1 Answers1

12

something more like

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

should give you 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.

Hellion
  • 1,740
  • 28
  • 36