What's the best way to convert the following statement to show the MMDDYYYY
format such as 02022013
without slashes or hyphens...
CONVERT (CHAR(10), A.POKFRM, 112)
Convert Char 'yyyymmdd' back to Date data types in SQL Server. Now, convert the Character format 'yyyymmdd' to a Date and DateTime data type using CAST and CONVERT. --A. Cast and Convert datatype DATE: SELECT [CharDate], CAST([CharDate] AS DATE) as 'Date-CAST', CONVERT(DATE,[CharDate]) as 'Date-CONVERT' FROM [dbo].
We can convert the Date into Datetime in two ways. Using CONVERT() function: Convert means to change the form or value of something. The CONVERT() function in the SQL server is used to convert a value of one type to another type. Convert() function is used to convert a value of any type to another datatype.
You could take a formatting that gives you elements in order but with /
or -
and then replace the /
or -
to get your desired result.
select REPLACE(CONVERT (CHAR(10), getdate(), 101),'/','')
Result:
02022015
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With