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

在 t-sql 中驗證日期?

validate a date in t-sql?(在 t-sql 中驗證日期?)
本文介紹了在 t-sql 中驗證日期?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我只想驗證來自用戶的給定輸入

I just want to validate a given input from the user

Declare @UserInput NVARCHAR(20)
set @UserInput = '26/07/2013'
select ISDATE(@UserInput)

這將返回 false,因為日期是澳大利亞格式,即使日期有效

This will return false as the date is in australian format, even though the date is valid

我可以將最后一行更改為以下內(nèi)容

I can change the last line to the folowing

select isdate(CONVERT(datetime, @UserInput, 103))

它的工作原理.但是如果@Userinput 是垃圾(即:- 'hello'),那么最后一條語句就會失敗.我怎樣才能擁有一些東西,無論用戶輸入什么,它都會將其驗證為澳大利亞日期 (dd/mm/yyyy)?

and it works. But if the @Userinput was rubbish (ie:- 'hello'), then the last statement would fail. How can I have something, where no matter what the user enters, it validates it to an australian date (dd/mm/yyyy)?

謝謝

推薦答案

使用 SET DATEFORMAT 指定您希望輸入的日期格式:

Use SET DATEFORMAT to specify the format you are expecting the date to be entered in:

SET DATEFORMAT DMY;

Declare @UserInput NVARCHAR(20)
set @UserInput = '26/07/2013'
select ISDATE(@UserInput)

我傾向于在輸入到達(dá) SQL-Server 之前執(zhí)行此類驗證,并確保任何日期變量都是日期.

I would be inclined to perform such validations prior to the input reaching SQL-Server, and ensuring that any date variables are dates.

這篇關(guān)于在 t-sql 中驗證日期?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 午夜视频成人 | 男女免费视频 | 激情网五月天 | 天天干女人| 亚洲欧美日韩国产 | 免费看黄色av | 久久久久久免费 | 久久综合久色欧美综合狠狠 | 日韩网站在线观看 | 一区二区影视 | 最新av在线播放 | 毛片毛片毛片 | 国产免费91 | 日韩少妇视频 | 香蕉网在线 | 成人小视频在线 | 久久精品毛片 | 中文字幕在线免费播放 | 国产精品三级在线观看 | 亚洲精品久久久久久久久 | 国产精品偷乱一区二区三区 | 精品一区二区三区在线观看 | 日本在线天堂 | 成人特级毛片 | 鲁鲁鲁鲁鲁鲁鲁777777 | 亚洲最新视频 | 午夜男人影院 | 国产三级在线播放 | 日本少妇高潮达到高潮 | www.日韩.com| 亚洲欧美一区二区三区在线 | 在线播放毛片 | 日韩精品少妇 | 日韩三级精品 | 欧美a在线观看 | 日韩av一区二区三区四区 | 欧美一区二区三区四区五区 | 国产无遮挡又黄又爽免费网站 | 日本少妇视频 | 国产激情久久 | 成年人视频网站 |