convert date to sql server format

Hi

How do i convert the datte in a date or datetime object into the format required by sql server which is

yyyy-mm-dd

is there a build is function?

thanks
andrea
andiejeAsked:
Who is Participating?
 
Praveen KumarArchitectCommented:
if i understand you correctly...

Dim d as DateTime
d=#6/25/2006#
Messagebox.Show(d.ToString("yyyy-MM-dd")

0
 
andiejeAuthor Commented:
thanks for your answer. It certainly is correct. However, I'm sure once on this forum someone told me of a built in function. It may have had internation or local or something like that in the name. I shall award you the points but do you happen to know what this other function may be?

thanks
andrea
0
 
shahprabalCommented:
if you are trying to convert strDate into date value, you can use cdate(strDate).ToShortDateString... you can enter date in dd/mm/yyyy format as well... sql server is not very picky
0
 
Praveen KumarArchitectCommented:
sorry, i dont remember such function name.
0
 
phillip_chapmanCommented:
You could also use the format function.

d=Microsoft.Visualbasic.Format(#6/25/2006#,"yyyy-MM-dd")

or

d=Microsoft.Visualbasic.FormatDateTime(#6/25/2006#,DateFormat.ShortDate)

This one is dependent upon the regional settings on your computer however.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.