Solved how to get difference between current date and given date?

June 30, 2016 at 02:39:12
Specs: Windows 7
i need to get diference between current date and given date in days then if days is 366 or 365 days should trigger a mail automatically

See More: how to get difference between current date and given date?

Reply ↓  Report •

✔ Best Answer
July 1, 2016 at 10:34:54

June 30, 2016 at 03:00:26
This is pretty straight forward but the thing is we need to know where you dates are and how your worksheet (assuming you are using Excel) is laid out. I have done this many times before but layout is essential so that we can read the dates.

Using vba you can use the DateDiff function to compare two dates for example, this will return the number of DAYS between dates using "d"

x = dateDiff("d", format(now(),"dd/mm/yyyy"),"01/07/2016")
Debug.Print x

this will give you 1 as 01/07/2016 is one day ahead of today

Please provide the structure of your worksheet using the Pre tags and we will do what we can to help.

Reply ↓  Report •

July 1, 2016 at 01:28:07
i have done like this : using but its showing "could not resolve the host "
i cant able to send the mail.

Imports System
Imports System.Net.Mail

Public Class Test
Public Shared Sub Main()
Dim D1 as Date = Now()
Dim D2 as Date = #7/20/2015#
Dim difference As TimeSpan = D1.Subtract(D2)
dim diff as decimal=math.round(difference.TotalDays)
if diff>=345 and diff<=366 then
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("", "Dot_1234")
SmtpServer.Port = 587
SmtpServer.Host = ""
mail = New MailMessage()
mail.From = New MailAddress("")
mail.Subject = "renew the application"
mail.Body = "This is to inform you that your application is going to expire in 15days.Kindly renew it soon."
MsgBox("mail send")
end if
End Sub
End Class

message edited by srinithasoundar

Reply ↓  Report •

July 1, 2016 at 02:15:52
Ahh so you want this in im not too good with .net so cant help

if this was Excel and vba I would be able to help.

Reply ↓  Report •

Related Solutions

July 1, 2016 at 02:17:59
no issues...thanks for your help ya

Reply ↓  Report •

July 1, 2016 at 10:34:54
✔ Best Answer

Reply ↓  Report •

Ask Question