Posts

Showing posts from August, 2014

Time Scalar Function

Everyone knows that you can use the Convert DML  to convert a DateTime data-type to a string evaluation for either split storage or display to an consuming interface. As most of us use the Date portion of a DateTime value for 90% of everything we are rendering the data to.  But what about that 10% where we either need to split render the Date & Time seperately.  After much review, we only have two quick and easy values to use and neither are really interchangeable. Option #1, with 2 forms: select convert(varchar(10), getdate(), 108) -- Produces: 13:53:15 select convert(varchar(15), getdate(), 114) -- Produces: 13:53:15:707 Now when using these forms of conversion, about 75% you have met the need for your requirement.  But lets say you need to use the Time string created for say a Filename ( sometext_[[TIME]].txt ), what do you do? Well the next code segment is what will be produced in order meet the FileName convention of special characters. select re