SQL Server的Datediff和Access的Datediff的区别

What function does: returns a variant to reflect the time difference between two dates

Syntax: DateDiff( inteval, firstdate, seconddate [,firstweekday[ [ , firstweek])

Example

The following shods the difference in days between two dates:

= DateDiff("d", "11-05-2002", "11-07-2002") returns 2


The following table lists the valid time periods and their interval values. 

参数 
Year
yyyy

Quarter
q

Month
m

Day of year
y

Day
d

Weekday
w

Week
ww

Hour
h

Minute
n

Second
s

Note: Take special care for "ww" vs "w." "WW" is for a week.


AgeYrs: DateDiff("d",[INSERVICE],Now())/365
Gives me this result:

14.5972602739726

in SQL the function:

AgeYrs = DATEDIFF(d,INSERVICE,getdate())/365

access中找出5分钟内注册的用户

select id,uid,pwd,addtime from [user] where DateDiff('n',addtime,now())<=5



[本日志由 webfly 于 2007-08-12 05:20 PM 编辑]
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.