Conversion error when converting 'nvarchar' to 'datetime' in sql server -


i have code :

declare @startdate nvarchar set @startdate='22/10/2014' select cast (@startdate datetime) 

and gives me error:

conversion failed when converting date and/or time character string.

can suggest better way/at least no error way this.

to convert string represents date in format dd/mm/yyyy can use this:

declare @startdate nvarchar(10) set @startdate='22/10/2014'      select convert(datetime, @startdate, 103) 

declaring varchar means setting length 1.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -