title: Encrypt a datetime field in mysql server
body: <p>I have 2 stored procedures <code>Encode</code>,<code>Decode</code> and i want to use this sp to convert my <code>datetime</code> column values (say <code>Dob</code>) to an encrypted date.<strong><em>The problem is that the encrypted format is not in datetime(varbinary) and hence it cant be inserted into that field</em></strong>.Changing the datatype or adding a new column doesn' favour me as my db is a huge one with lots of tables and sps.The steps I use presently is:</p>
  
  <pre><code>declare @datetime
  set @datetime='01/02/2008 12:45 PM'
  declare @secretDate varchar(400)
  declare @date varchar(200)
  set @date=(select Convert(varchar(200),@datetime,120)
  EXEC @secretDate=dbo.Encode @date
  set @date=(select Convert(varchar(200),@secretdate,120))
  select Convert(varchar(200),convert(varbinary(MAX),@date)) as EncryptedDate
  </code></pre>
  
  <p>Any suggestion is appreciated!</p>