SQL Server 默认日期时间戳? [英] SQL Server default date time stamp?

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

问题描述

我有一个字段,当插入某些内容时,我希望它获取当前日期 &计时并将其插入到数据库中.有没有办法获得日期&时间,并将其设置为默认值?

I have a field that when something is inserted I want it to get the current Date & Time and insert this into the database. Is there a way to get the date & time, and set it as the default value?

目前默认值是:(getdate()) 只设置日期.我还怎么设置时间?

Currently the default value is: (getdate()) Which sets only the date. How do I also set the time?

推荐答案

GETDATE() 是 SQL Server 中的日期和时间.

GETDATE() is a date and time in SQL Server.

运行 SELECT GETDATE() 来验证这一点.

Run SELECT GETDATE() to verify this.

您的字段的数据类型是什么?如果是 DATE 那么它也不会保存时间值.

What is the datatype of your field? If it's DATE then it will not hold time values as well.

这篇关于SQL Server 默认日期时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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