title: How to get DateTime in yyyymmddhhmmss
body: <p>I have written the below query to create an xml from entity, I need to get date time in .NET in <code>yyyymmddhhmmss</code> format for the field <code>SLOTTINGTIME</code>, so I have thought of writing a new method to get date time in desired format. </p>
  
  <pre><code>var slottingmessagexml = new XDocument(new XElement("Message",
      new XAttribute("ID","SLT"),
      new XElement("Record",
          new XAttribute("STORENO",slottingmessage.StoreID),
          new XAttribute("PICKLOCATION",slottingmessage.PickLocation),
          new XAttribute("TPNB",slottingmessage.ProductID),
          new XAttribute("SLOTTINGTIME",GetDateTimeInNewFormat(slottingmessage.SlottingDateTime)),
          new XAttribute("SLOTTTINGACTION",slottingmessage.SlottingAction))
      )
  );
  </code></pre>