Concatenate text from two fields not working

344
2
Jump to solution
07-22-2019 02:32 PM
MalcolmLittle
New Contributor III

Hello,

Within ArcPro 2.4, I'm trying to calculate a new field from two existing fields. The first field is an ID field of type text, and the second is a full date and time field of type Date. I want to separate the two with an underscore. I use the following in the Field Calculator:

Problem is, my results end up being <Null> for the new column AKEY. The new column AKEY is type text, with 8000 length.

1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

ArcGIS Pro thinks your Python expression is valid, so if you are getting lots of Null, it makes me wonder if you have a selection on the table so you are only calculating for a small subset of records but looking at all the records afterwards.

View solution in original post

2 Replies
DanPatterson_Retired
MVP Esteemed Contributor
import datetime

idval = '1'

nw = datetime.datetime.now()

"{}_{}".format(idval, nw)

'1_2019-07-22 17:36:38.897392'

python formatter will convert anything to a string which can be used in concatenation

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

ArcGIS Pro thinks your Python expression is valid, so if you are getting lots of Null, it makes me wonder if you have a selection on the table so you are only calculating for a small subset of records but looking at all the records afterwards.