当前位置:首页 科普知识 getdate

getdate

发布时间:2023-09-14 00:58:06

getdate,是一个函数术语,GETDATE() 函数从 SQL Server 返回当前的时间和日期。

getdate介绍

getdate,是一个函数术语,GETDATE() 函数从 SQL Server 返回当前的时间和日期。

getdate语法功能

功 能: GETDATE() 函数从 SQL Server 返回当前的时间和日期。

列:SELECT GETDATE() AS CurrentDateTime

结果:

CurrentDateTime

2008-12-29 16:25:46.635

列:--取时间的某一个部分

select datepart(yy,getdate()) --year

select datepart(mm,getdate()) --month

select datepart(dd,getdate()) --day

select datepart(hh,getdate()) --hour

select datepart(mi,getdate()) --min

select datepart(ss,getdate()) --sec

函数名: getdate

功 能: 取DOS日期

用 法: void getdate(struct *dateblk);

程序例:

#include<stdio.h>

#include <dos.h>

int main(void)

{

struct date d;

getdate(&d);

printf("The current year is: %dn",

d.da_year);

printf("The current day is: %dn",

d.da_day);

printf("The current month is: %dn",

d.da_mon);

return 0;

}

getdate备注信息

在VC++6.0中运行上述程序不能通过,原因是此版本的<dos.h>中不包含getdate函数。

但在TurboC 中运行可以通过。

温馨提示:
本文【getdate】由作者 爱百科 转载提供。 该文观点仅代表作者本人, 自学教育网 信息发布平台,仅提供信息存储空间服务, 若存在侵权问题,请及时联系管理员或作者进行删除。
(c)2008-2025 自学教育网 All Rights Reserved 汕头市灵创科技有限公司
粤ICP备2024240640号-6