将日期时间转换为日期 [英] converting datetime to a date

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

问题描述

当我尝试这个:cast(datetime_field as date)我收到一条错误消息类型日期不是定义的系统类型。



如何转换如果日期不是定义的系统类型,则字段的日期时间不包括小时,分钟和秒?

When I try this: cast(datetime_field as date) I get an error message "Type date is not a defined system type."

How do I convert a datetime to a field without hours, minutes, and seconds if date is not a defined system type?

推荐答案

convert(datetime,YourDate,103)



103是dd / MM / yyyy的格式
convert(datetime, YourDate, 103)

103 is the format for dd/MM/yyyy


你可以在这里看到:

日期和时间数据类型和函数(Transact-SQL) [ ^ ]

特别是 DATEFROMPARTS [ ^ ]功能。
You may see here:
Date and Time Data Types and Functions (Transact-SQL)[^]
especially the DATEFROMPARTS[^] function.


这篇关于将日期时间转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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