title: Converting timestamp field to date type and using it as partition in AWS Glue ETL
body: <p>I'm trying to create a partition on one of the fields in csv and store it as parquet using Glue ETL (python). Problem is, this field is a timestamp so before creating a partition, I want to extract date from this timestamp and store it in a field and then use this new field to create a partition.</p>
  
  <p>Here is my code below. I want to extract date from <code>verificationdatetime</code> field into a field called <code>verificationdate</code> and then add it as <code>partitionkey</code> while writing to the DynamicFrame. Any ideas?</p>
  
  <pre><code>args = getResolvedOptions(sys.argv, ['JOB_NAME'])
  
  sc = SparkContext()
  glueContext = GlueContext(sc)
  spark = glueContext.spark_session
  job = Job(glueContext)
  job.init(args['JOB_NAME'], args)
  
  datasource0 = glueContext.create_dynamic_frame.from_catalog(database 
  = "sample_database", table_name = "sample_table", transformation_ctx 
  = "datasource0")
  
  applymapping1 = ApplyMapping.apply(frame = datasource0, mappings = 
  [("personid", "string", "personid", "string"), 
  ("verificationdatetime", "string", "verificationdatetime"), ], transformation_ctx = "applymapping1")
  
  resolvechoice2 = ResolveChoice.apply(frame = applymapping1, choice = 
  "make_struct", transformation_ctx = "resolvechoice2")
  
  dropnullfields3 = DropNullFields.apply(frame = resolvechoice2, 
  transformation_ctx = "dropnullfields3")
  
  datasink4 = glueContext.write_dynamic_frame.from_options(frame = 
  dropnullfields3, connection_type = "s3", connection_options = 
  {"path": "s3://samplebucket/samplefile/","partitionKeys":["type"]}, 
  format = "parquet", transformation_ctx = "datasink4")
  
  job.commit()
  </code></pre>