My table structure like this
我的表结构是这样的
I am create view for this table
我正在为这个表创建视图
SELECT Entered FROM dbo.tbPatientReport
SELECT从dbo.tbPatientReport输入
In the table data like this
在这样的表数据中
If i execute view from sql query then it will give output like
如果我从sql查询执行视图,那么它将给出输出
select Entered from view_abc
选择从view_abc输入
Desired Output
3 个解决方案
#1
2
You should format date as you want in result. e.g.
您应该根据需要在结果中格式化日期。例如
SELECT FORMAT( Entered,'MM/dd/yyyy hh:mm:ss tt','en-US') AS 'US'
FORMAT is one of the new built-in String Function introduced as a Part of Sql Server 2012. It returns the value formatted in the specified format using the optional culture parameter value. It is not an Sql Server native function instead it is .NET CLR dependent function.
FORMAT是作为Sql Server 2012的一部分引入的新的内置字符串函数之一。它使用可选的culture参数值返回以指定格式格式化的值。它不是Sql Server本机函数,而是.NET CLR依赖函数。
SYNTAX: FORMAT ( value, format [, culture ] )
语法:格式(值,格式[,文化])
Edit Can you test this will be working.
编辑您可以测试这将是有效的。
SELECT CONVERT(VARCHAR(20), SYSDATETIME(), 22)
Format: MM/DD/YY HH:MI:SS AM
Output: 10/25/13 2:21:00 PM
Only problem is you cannot get FullYear.
唯一的问题是你无法获得FullYear。
#2
1
I got link Date and Time function
我有链接日期和时间功能
for the date and time conversion In this link all the date and time function available
用于日期和时间转换在此链接中可用的所有日期和时间功能
#3
0
Your [Entered] column [Datetime] in your table structure does not allow nulls, it's not ticked.
表结构中的[输入]列[日期时间]不允许空值,也不会勾选。
What version of SQL Management Studio are you using? And are you selecting the data in a plain select query or are you choosing to View the data? In older versions "View" opens the edit window with your code on top.
您使用的是什么版本的SQL Management Studio?您是在普通选择查询中选择数据还是选择查看数据?在旧版本中,“查看”会打开编辑窗口,代码位于顶部。
While in the editing view the last row will always be NULL as it is expecting new data.
在编辑视图中,最后一行将始终为NULL,因为它需要新数据。
#1
2
You should format date as you want in result. e.g.
您应该根据需要在结果中格式化日期。例如
SELECT FORMAT( Entered,'MM/dd/yyyy hh:mm:ss tt','en-US') AS 'US'
FORMAT is one of the new built-in String Function introduced as a Part of Sql Server 2012. It returns the value formatted in the specified format using the optional culture parameter value. It is not an Sql Server native function instead it is .NET CLR dependent function.
FORMAT是作为Sql Server 2012的一部分引入的新的内置字符串函数之一。它使用可选的culture参数值返回以指定格式格式化的值。它不是Sql Server本机函数,而是.NET CLR依赖函数。
SYNTAX: FORMAT ( value, format [, culture ] )
语法:格式(值,格式[,文化])
Edit Can you test this will be working.
编辑您可以测试这将是有效的。
SELECT CONVERT(VARCHAR(20), SYSDATETIME(), 22)
Format: MM/DD/YY HH:MI:SS AM
Output: 10/25/13 2:21:00 PM
Only problem is you cannot get FullYear.
唯一的问题是你无法获得FullYear。
#2
1
I got link Date and Time function
我有链接日期和时间功能
for the date and time conversion In this link all the date and time function available
用于日期和时间转换在此链接中可用的所有日期和时间功能
#3
0
Your [Entered] column [Datetime] in your table structure does not allow nulls, it's not ticked.
表结构中的[输入]列[日期时间]不允许空值,也不会勾选。
What version of SQL Management Studio are you using? And are you selecting the data in a plain select query or are you choosing to View the data? In older versions "View" opens the edit window with your code on top.
您使用的是什么版本的SQL Management Studio?您是在普通选择查询中选择数据还是选择查看数据?在旧版本中,“查看”会打开编辑窗口,代码位于顶部。
While in the editing view the last row will always be NULL as it is expecting new data.
在编辑视图中,最后一行将始终为NULL,因为它需要新数据。