SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Convert Date English and French
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

infodemers
Posting Yak Master

Canada
181 Posts

Posted - 09/30/2012 :  00:14:49  Show Profile  Reply with Quote
Hi,

I use the following to convert a date.
English:
Select CONVERT(DATE, '1-' + 'jan-2012') --> returns 2012-01-01

French:
Select CONVERT(DATE, '1-' + 'janv.-2012')
returns Conversion failed when converting date and/or time from character string.

Any idea?

khtan
In (Som, Ni, Yak)

Singapore
17586 Posts

Posted - 09/30/2012 :  02:11:31  Show Profile  Reply with Quote
what is your language ?

select	@@language


for French, try set the language to French before convert.
SET LANGUAGE N'French'


refer to http://msdn.microsoft.com/en-us/library/ms174398.aspx


KH
Time is always against us

Go to Top of Page

infodemers
Posting Yak Master

Canada
181 Posts

Posted - 09/30/2012 :  09:16:50  Show Profile  Reply with Quote
You are right khtan!

I also found out, I have the remove the dot in the month name to get it work with the language setting!
SET LANGUAGE N'French'
Select CONVERT(DATE, '1-' + 'janv-2012')
SET LANGUAGE N'English'
Select CONVERT(DATE, '1-' + 'jan-2012')

Thanks a lot for your help!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 10/01/2012 :  10:50:09  Show Profile  Reply with Quote
this is the problem of trying to store dates as text format. Always try to store date values as date itself if possible and pass values in an unambiguos format

http://visakhm.blogspot.com/2011/12/why-iso-format-is-recommended-while.html



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 10/05/2012 :  04:58:44  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Always use unambiguous date format http://beyondrelational.com/modules/2/blogs/70/posts/10898/understanding-datetime-column-part-ii.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000