The birthday is tomorrow but i need to check one day before

I have an excel with the birthdate, so i need to send a mail tomorrow is the birthday.
So am comparing today’s date with tomorrows birthday date.
if the birthday date is on 1st December and current date is on 30th November. If i do subtract in the birthday date it will not match with the today’s date.
So any one help me regarding this.
So my requirements is i need to send a mail today if the birthday is tomorrow.

Hi @Vanitha_VS

Try this:

Dim currentDate As DateTime = DateTime.Now
Dim tomorrowDate As DateTime = currentDate.AddDays(1)

For Each row As DataRow In dt.Rows
    Dim birthdateString As String = row("Birthdate").ToString()
    Dim birthdate As DateTime = DateTime.ParseExact(birthdateString, "your_date_format", CultureInfo.InvariantCulture)

    ' Check if the birthday is tomorrow
    If tomorrowDate.Day = birthdate.Day AndAlso tomorrowDate.Month = birthdate.Month Then
        ' Send email logic goes here
      
    End If
Next

If possible share the excel data to help you out with logic.

Hope it helps!!

HI @Vanitha_VS

Can you try with this below date condition

DateTime.ParseExact(CurrentRow("Birthday Date").ToString.Trim,{"dd-MMM-yy","d-MMM-yy","dd-MMM-yyyy","MM/dd/yyyy 00:00:00","MM/d/yyyy 00:00:00","MM/dd/yy 00:00:00"}, System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("dd-MM").Equals(Now.Addays(1).ToString("dd-MM")) 

image

Hello @Vanitha_VS

  1. Assign activity:
    birthdateColumnIndex = dt.Columns.IndexOf(“BirthdateColumn”) // Replace “BirthdateColumn” with your actual column name
    tomorrow = DateTime.Now.AddDays(1).Date

  2. For Each Row activity (Input: dt):
    a. Assign activity:
    birthdate = DateTime.ParseExact(row(birthdateColumnIndex).ToString, “dd/MM/yyyy”, CultureInfo.InvariantCulture)

    b. If activity:
    Condition: birthdate.Month = tomorrow.Month AndAlso birthdate.Day = tomorrow.Day
    Then:
    Send email or perform other actions

Thanks & Cheers!!!

@Vanitha_VS

use this in if activity

DateDiff(DateInterval.Day,datetime.ParseExact("12/01/2023","MM/dd/yyyy",system.Globalization.CultureInfo.InvariantCulture),datetime.ParseExact("11/30/2023","MM/dd/yyyy",system.Globalization.CultureInfo.InvariantCulture))=-1

if you want to compare with the present day,use this in if activity

DateDiff(DateInterval.Day,datetime.ParseExact("12/07/2023","MM/dd/yyyy",system.Globalization.CultureInfo.InvariantCulture),cdate(now.ToString("MM/dd/yyyy")))=-1

whenever working with datediff we keep in mind, the way how fractions are handled.
grafik

we can see, that 2 different days are resulting to 0

Hi

Extract Birthdate: Read the birthdate from the Excel cell and convert it to a date object.
Get Today’s Date: Use the Now function to get today’s date.
Extract Birth Month and Day: Extract the month and day components from the birthdate.
Calculate Tomorrow’s Date:

DateTime tomorrow = DateTime.Now.AddDays(1);
// Check if tomorrow’s month and day match the birthday
if (tomorrow.Month == birthdate.Month && tomorrow.Day == birthdate.Day) {
// Send birthday email
}