自定义格式的日期格式 [英] Dateformatting from Custom Format

查看:99
本文介绍了自定义格式的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的软件(C#)格式化自定义Windows DateTime格式时出现问题.
我需要能够将DD.MMM.YY(09.Mar.12)的日期时间转换为默认的德国DateTime DD.MM.YYYY(09.03.2012)?我该怎么做才是最好的方法?

SQL-Server设置为德语Datetime,并且不接受DD.MMM.YY之类的DateTime格式(将varchar转换为datetime时出错).

---------------------------------------------
区域设置:
---------------------------------------------

-Windows系统区域设置为德国
-DatetimeFormat短的"DD.MMM.YY"
-DatetimeFormat Long"DD.MMM.YYYY"(是的,这确实有空格!)


欢迎任何建议(作为SQL查询和/或C#代码).

My Software (C#) has a problem formatting a custom Windows DateTime-Format.
I need to be able to convert a Datetime from DD.MMM.YY (09.Mar.12) to a default German DateTime DD.MM.YYYY (09.03.2012)? How can i do this the best way?

The SQL-Server is set to German Datetime, and is not accepting a DateTime-format like DD.MMM.YY (error converting varchar to datetime).

---------------------------------------------
Region Settings:
---------------------------------------------

- Windows System Region is set to Germany
- DatetimeFormat Short "DD.MMM.YY"
- DatetimeFormat Long "DD. MMM . YYYY" (yes, this really has spaces!)


Any suggestions are welcome (as SQL-Query and/or as C# Code).

推荐答案

感谢大家.
我已经实现了Bernhard的解决方案.
效果很好!

谢谢大家.
Thanks to you all.
I have implemented Bernhard''s Solution.
It works fine!

Thank you all.


设置为查询中的第一条命令:
设置语言德语
(请参见此处 [此处 [^ ])
在这种情况下,您将能够转换日期时间
set as first command in your query:
set language German
(see here[^] and here[^])
In that case you will be able to convert your datetime


http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/[^]
Just try this Link...!
Regards..!
Dnyanesh


这篇关于自定义格式的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆