开发者

How can I insert a new row by writing a query in SQL Server in my own format?

I am trying to execute a query to insert rows in to a table in SQL Server. As, its simple it is working fine and insert a row for datetime column in yyyy-MMM-dd hh:mm:ss ttt format. My problem is I have to insert the row in dd/MMM/yyyy hh:mm:ss开发者_如何学JAVA ttt format. Is it possible to do this through a query in SQL Server?


Yes, it is possible. It also is a sensless attempt. WHY do you want to introduce some culture specific date coding into your database access coding?

yyyy-MMM-dd hh:mm:ss ttt format

This is the ISO culture independant format that works regardless of what the user's computer is set to. It is there for a reason.

My Problem is i have to insert the row in dd/MMM/yyyy hh:mm:ss ttt format

No, you do not. You just are under the illusion. You ahve to insert a date time into sql server. NOTHING says you can not format it properly first.

Why do you HAVE to insert it in this particular specific format?


That should work fine, especially as the month component is MMM not MM (which can cause conversion problems).


as far as i know SQL server stores the date time in the same format internally, no matter what you give it. parsing the string to a datetime is another matter. to use different formats you can use the CONVERT function and provide the style argument, i think 113/13 is closest to what you specified

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜