Calculating Date for ArcSDE gdb - not getting Hours, Minutes, Seconds

285
1
05-07-2012 09:10 AM
SaraShullaw
New Contributor
Hello,

I'm trying to calculate a date field for a feature class in an ArcSDE gdb using Python. My script successfully calculates the year, month, day but only calcs zeros for hours minutes seconds. Can you help? Here is the relevant portion of my script:

# Import system modules
import arcpy, os, sys
from arcpy import env
import datetime

nowDate = datetime.datetime.now()
dateExp = nowDate.strftime("%Y-%m-%d %H:%M:%S")
arcpy.CalculateField_management("selectLyr", "UpdDate", "date '" + dateExp + "'", "", "")
Tags (2)
0 Kudos
1 Reply
DavidWynne
Esri Contributor
Hi Todd,
You could use the datetime object directly, sort of like below
arcpy.CalculateField_management("selectLyr", "UpdDate", `datetime.datetime.now()`, "PYTHON")


-Dave


Note: I'm using backtick's around the datetime when pushing it into the tool (just stating this in case that isn't obvious)
0 Kudos