Search code examples
sqldatesql-server-ce

Get Formatted Date in SQL Server CE


How to get the formatted date in SQL Server CE?

I have a column on a table that contains Date, but the column type is nvarchar

ID     Date
----------------------
1      05/08/2012
2      10/08/2012
3      05/10/2012

The date format is MM/dd/yyyy, but it is in nvarchar.

Also, I want to have a WHERE clause to select the ID on a specific date. How can I do that? This is for SQL Server CE. Thank you very much.


Solution

  • you need to cover it use convert or cast function ...

    cast(datecolumn as DateTime)
    

    or

     CONVERT(datetime,datecolumn,101)