I think you want something like the second bullet point in:

  

      github.com/tensorflow/transform
  

  
    
  
	  
  

  
    
      Transforming date values 11
    

    
      
        opened 
        
          
        
        Apr 23, 2019
      
      


      
        
          
          Malonl
        
      
    

    
        stat:awaiting tensorflower
        type:feature
    
  


  
    Hi.

I have a use case where I want to use date features as input values for a… predictive model. I need to transform the date features to be useful.

Examples I would like to be able to do: 
- Given two date columns, generate a new column with the difference between them in days. The days can be days, weeks, or even years apart
- From a column with dates, create three different columns with extracted data, one for day, one for month, one for year

If we could use some python library (datetime for example), it would be trivial. Without the library, we would need to implement the knowledge about the calendar (number of days in each month etc)
I believe we cannot use a conventional python library because if we use it, the transformation would not be written to the graph, and thus we would not be able to have it at serving time.

My question is if it is possible to do this within TF Transform and if not, is this a feature that is coming up?
If there is no way such operations to the graph, we would need to implement a piece of pipeline transforming the data both before training and before serving, outside of the graph.

Thanks in advance!

PS: For transparancy, I have asked this question on [tensorflow/tensorflow](https://github.com/tensorflow/tensorflow/issues/27893#issuecomment-484983991) and [tensorflow/tfx](https://github.com/tensorflow/tfx/issues/41#issuecomment-485289180) as well, but have been redirected to this forum.