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

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

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

問題描述

在 Microsoft SQL Server 2005 和 .NET 2.0 中,我想將當前日期轉換為以下格式的字符串:YYYY-MM-DD".例如,2009 年 12 月 12 日將變為2009-12-20".我如何在 SQL 中執行此操作.

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 語句的上下文.換句話說,這是默認值.因此,當創建新記錄時,當前日期的默認值以上述格式存儲為字符串.

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 服務器不斷將其轉換為:('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]')

所以結果就是:

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

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

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

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

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

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

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

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

這是我將所有內容連接到 ASP.NET GridView 并嘗試通過網格視圖進行更新時遇到的錯誤:

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 版本不支持數據類型日期".說明:在執行當前 Web 請求期間發生未處理的異常.請查看堆棧跟蹤以獲取有關錯誤及其在代碼中的來源的更多信息.

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.

異常詳細信息:System.ArgumentException:正在使用的 SQL Server 版本不支持數據類型日期".

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

源錯誤:

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

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 版本不支持數據類型日期".]

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

注意:我添加了一個相關問題來嘗試解決 正在使用的 SQL Server 不支持數據類型日期"錯誤,因此我可以按照建議使用 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.

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

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

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
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屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 999久久久 | 特级黄一级播放 | 日韩在线视频一区二区三区 | 日韩国产精品一区二区三区 | 欧美v免费 | 日韩视频在线免费观看 | 国产1区2区 | 一区二区三区在线观看视频 | 免费黄篇| 欧美日韩久久 | 国产精品18久久久久久白浆动漫 | 日韩在线免费观看视频 | 亚洲二区在线 | 亚洲精品日日夜夜 | 日韩精品一 | 精品国产伦一区二区三区观看说明 | 伊人欧美视频 | 久久久久国 | 麻豆成人在线视频 | 中文字幕亚洲视频 | 色噜噜狠狠色综合中国 | 97人人澡人人爽91综合色 | 91就要激情 | 91看国产 | 99免费精品| 美女视频黄色的 | 国产一区在线免费 | 日韩国产在线 | 日韩欧美在线一区 | 国产一区二区三区高清 | 四虎最新视频 | 免费一区二区三区 | 亚洲精品丝袜日韩 | 69热视频在线观看 | 亚洲精品乱码久久久久久按摩 | 久久久这里都是精品 | 欧美精品一区二区三区四区 在线 | 欧美a在线看 | 亚洲日韩中文字幕 | 日韩在线一区二区 | 精品视频一区二区三区在线观看 |