久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SQL Server getdate() 轉(zhuǎn)換為類似“2009-12-20"的字符

SQL Server getdate() to a string like quot;2009-12-20quot;(SQL Server getdate() 轉(zhuǎn)換為類似“2009-12-20的字符串)
本文介紹了SQL Server getdate() 轉(zhuǎn)換為類似“2009-12-20"的字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

在 Microsoft SQL Server 2005 和 .NET 2.0 中,我想將當(dāng)前日期轉(zhuǎn)換為以下格式的字符串:YYYY-MM-DD".例如,2009 年 12 月 12 日將變?yōu)?009-12-20".我如何在 SQL 中執(zhí)行此操作.

In Microsoft SQL Server 2005 and .NET 2.0, I want to convert the current date to a string of this format: "YYYY-MM-DD". For example, December 12th 2009 would become "2009-12-20". How do I do this in SQL.

表定義中此 SQL 語句的上下文.換句話說,這是默認(rèn)值.因此,當(dāng)創(chuàng)建新記錄時,當(dāng)前日期的默認(rèn)值以上述格式存儲為字符串.

The context of this SQL statement in the table definiton. In other words, this is the default value. So when a new record is created the default value of the current date is stored as a string in the above format.

我正在嘗試:SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]

I'm trying: SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]

但 SQL 服務(wù)器不斷將其轉(zhuǎn)換為:('SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]')

But SQL server keeps converting that to: ('SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]')

所以結(jié)果就是:

'SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]'

'SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]'

以下是 Visual Studio 服務(wù)器資源管理器、表、表定義、屬性顯示的屏幕截圖:

Here's a screen shot of what the Visual Studio server explorer, table, table definition, properties shows:

這些包裝器位正在自動添加并將其全部轉(zhuǎn)換為文字字符串:(N' ')

These wrapper bits are being adding automatically and converting it all to literal string: (N' ')

這就是我嘗試使用我之前使用的基本 DATETIME 以外的其他內(nèi)容的原因:

Here's the reason I'm trying to use something other than the basic DATETIME I was using previously:

這是我將所有內(nèi)容連接到 ASP.NET GridView 并嘗試通過網(wǎng)格視圖進(jìn)行更新時遇到的錯誤:

This is the error I get when hooking everything to an ASP.NET GridView and try to do an update via the grid view:

正在使用的 SQL Server 版本不支持?jǐn)?shù)據(jù)類型日期".說明:在執(zhí)行當(dāng)前 Web 請求期間發(fā)生未處理的異常.請查看堆棧跟蹤以獲取有關(guān)錯誤及其在代碼中的來源的更多信息.

The version of SQL Server in use does not support datatype 'date'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

異常詳細(xì)信息:System.ArgumentException:正在使用的 SQL Server 版本不支持?jǐn)?shù)據(jù)類型日期".

Exception Details: System.ArgumentException: The version of SQL Server in use does not support datatype 'date'.

源錯誤:

在執(zhí)行當(dāng)前 Web 請求期間生成了未處理的異常.可以使用下面的異常堆棧跟蹤來識別有關(guān)異常來源和位置的信息.

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

堆棧跟蹤:

[ArgumentException: 正在使用的 SQL Server 版本不支持?jǐn)?shù)據(jù)類型日期".]

[ArgumentException: The version of SQL Server in use does not support datatype 'date'.]

注意:我添加了一個相關(guān)問題來嘗試解決 正在使用的 SQL Server 不支持?jǐn)?shù)據(jù)類型日期"錯誤,因此我可以按照建議使用 DATETIME.

Note: I've added a related question to try to get around the SQL Server in use does not support datatype 'date' error so that I can use a DATETIME as recommended.

推薦答案

http://www.sql-server-helper.com/tips/date-formats.aspx

獲取所有日期時間格式的列表.

For a list of all the date time formats.

這篇關(guān)于SQL Server getdate() 轉(zhuǎn)換為類似“2009-12-20"的字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標(biāo)記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 中文字幕综合 | 亚洲视频中文字幕 | 日韩免费一区二区 | 伊人精品国产 | 午夜男人天堂 | 欧美精品 在线观看 | 久久免费精品视频 | 国产一区二区在线免费观看 | 成人国产精品入口免费视频 | 国产欧美日韩综合精品一 | 伊人网综合在线 | 在线观看免费福利 | 男女啪啪高潮无遮挡免费动态 | 日韩午夜 | 涩涩视频在线观看免费 | 免费一级片 | 久久99久久98精品免观看软件 | 日韩视频福利 | 国产乱码精品一区二区三区忘忧草 | 精品国产99 | 视频1区| 国产精品成人一区二区 | 精品欧美激情精品一区 | 欧美天堂 | 国产欧美精品一区 | 999久久久久久久 | 亚洲网站免费看 | www.99热 | 亚洲一区二区三区四区五区午夜 | www.玖玖玖| 久久久国产精品视频 | 国产成人av免费看 | 性色av网站 | 成年无码av片在线 | 国产日韩一区二区 | 亚洲一区不卡在线 | 成人免费在线观看 | 亚洲成人精品在线观看 | 黄色成人在线网站 | 久久久精品一区二区三区 | 国产欧美一区二区三区在线播放 |