Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k 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?

closed

1 Answer

+1 vote
by (47.2k 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.

Intellipaat offers Tableau Training for the learners to master advanced visualization tools. 

Related questions

+1 vote
2 answers
+2 votes
3 answers
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...