ArcMap - Trim left in Attribute table?

777
4
Jump to solution
08-16-2018 09:48 AM
JordanMiller4
Occasional Contributor III

Does anyone know how to trim everything after each date? We'd like to remove all the 4:00:00 AM from the database at once.

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

Calling time.strftime this way will result in the current time as returned by localtime() being populated in the field, which isn't my understanding of what the OP wants.  The following will keep the current date and strip the time when working with Field Calculator:  !DATE_FIELD!.split()[0]

View solution in original post

4 Replies
JoeBorgione
MVP Esteemed Contributor

As long as your date filed is not controlled by edit tracking, you should be able to use the field calculator with the Python parser this way:

That should just about do it....
JoshuaBixby
MVP Esteemed Contributor

Calling time.strftime this way will result in the current time as returned by localtime() being populated in the field, which isn't my understanding of what the OP wants.  The following will keep the current date and strip the time when working with Field Calculator:  !DATE_FIELD!.split()[0]

JoeBorgione
MVP Esteemed Contributor

Interesting; I tried it before I posted it and thought it trimmed it as the op was hoping for...  I'll try it again when I get into the office....

edited a later at the office:  Yep; you are 100% correct Joshua!  As I recall I, I tested it on a new test table/date attribute so it looked like it worked.  For the op, here is what happens to existing data:

 Existing date field: 

 

After the edit as I showed:

No bueno!

Go with Joshua's solution!  Muy Bueno!

Joshua Bixby

Dan Patterson :  would you please give the answer to JosHua?

That should just about do it....
0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

I would if I could but my powers don't extend to Enterprise

Michelle Mathias‌ could you use the wand of correctness on Josh's post if Jordan doesn't