2个日期之间的日期差 [英] Date difference between 2 dates

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

问题描述

大家好,

我需要发送邮件

StartDate-今天= 7

即在7天之前,邮件应从开始日期起发送给用户

帮助pl

问候,
Praveen

Hello all,

I need to send a mail

StartDate - today =7

i.e., Before 7 days the mail should send the user from the start date

Help pl

Regards,
Praveen

推荐答案

尝试:
SELECT * FROM myTable where DATEDIFF( dd, [date],GETDATE())=7


给您一个想法;
为了获取日期,请使用;

To give you an idea;
For getting the date use;

SELECT DATEADD(d,-7,GETDATE())



用于发送电子邮件;



For sending email use;

CREATE PROCEDURE dbo.foo AS
BEGIN
    SET NOCOUNT ON
    -- do some other actions
    DECLARE @body VARCHAR(1024)
    SET @body = 'foo was fired '+
        CONVERT(VARCHAR, GETDATE())
    EXEC master..xp_smtp_sendmail
        @TO = 'you@you.com',
        @from = 'someone@somewhere.com',
        @message = @body,
        @subject = 'foo was fired.',
        @server = 'smtp.yourdomain.com'
END




要发送电子邮件选项,请点击链接 [ ^ ].

对于日期函数,请查看此处 [ ^ ].

因此,这应该使您知道如何执行此操作.

祝你好运.




For sending email options check this link[^].

For date functions have a look at here[^].

so this should give you an idea how you can do it.

Good luck.


使用 DATEADD [ ^ ]函数

例如
Use the DATEADD [^] function

e.g.
WHERE DATEADD(d, -7, GETDATE()) >= StartDate


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

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