Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to convert datetime in SQL server compact edit

Author  Topic 

shinelawrence
Starting Member

32 Posts

Posted - 2013-09-07 : 05:01:44
Hi Everyone,
I used datetime conversion in SQL server compact edition, but i got error: The specified data type is not valid [ Data type (if known)= varchar]...but it's working in sqlserver 2008.. Pls tell the solution....
I used this sample query only.
SELECT CAST(GETDATE() AS varchar(10))

Thanks In Advanced

Cooper-5
Starting Member

10 Posts

Posted - 2013-09-09 : 09:35:12
the only issue i can see with the cast is that it is for 10 characters, the outcome of that cast requires 11 characters.

could you try the below and see if it does what you require, as the conversion can output different formats depending on the integer you supply as the last parameter (e.g. 103,112, etc...)

select convert(varchar(11), getdate(), 103)

hope this helps

Nothing is truly idiot proof, because the world keeps producing a higher class of idiot
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-09-11 : 14:03:24
I don't think SQL CE supports VARCHAR. Try NVARCHAR instead.
Go to Top of Page
   

- Advertisement -