Getting wrongs results using a filter for the acivity "Get oulook mail messages"

I’m using this filter:

“[ReceivedTime] >= '”+FechaForm.ToShortDateString+"’ AND [ReceivedTime] <= ‘"+FechaForm.AddDays(1).ToShortDateString +"’"

Where, FechaForm = 03/06/2021 (dd/mm/yyyy)
The filter applied is: [ReceivedTime] >= ‘03/06/2021’ AND [ReceivedTime] <= ‘03/07/2021’

So, the second date is adding a month, not a day, as this part of my filter says: FechaForm.AddDays(1).ToShortDateString

The mails found > 0 , but it is retrieving not only the emails for 03/06/2021 (dd/mm/yyyy) but since that day to ‘03/07/2021’ (dd/mm/yyyy).

I only need the emails for one day = 03/06/2021 (dd/mm/yyyy)

But, if FechaForm= 06/03/2021 (mm/dd/yyyy)

The filter applied is: [ReceivedTime] >= ‘06/03/2021’ AND [ReceivedTime] <= ‘04/06/2021’

but the mails found = 0, even when there is emails on date 06/03/2021 (mm/dd/yyyy) in outlook folder.

It seems your date format is MM/dd/yyyy format. that’s why adddays(1) is adding plus one to your 2nd element which is day.

What is FechaForm variable type??


Hello @prasath17
Thanks for your reply.

Fechaform is datetime type

@Ana_Blanco - May I ask how did you assign the values to Fechaform??

As I mentioned above, When you assigned it took as MM/dd/yyyy format because new Datetime will yyyy, MM, dd format.



dateFechaformateada = Datetime.ParseExact(strFechaFormateada,“M/d/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

strFechaFormateada= “06/03/2021” (MM/DD/YYYY)


I must say, this way I’m managing the dates and filters worked ok for two months, on 31/05/2021 it starts to fail :frowning:

Should I ckeck the system format date or Outlook format date?

Regards and thanks

-for example, If FechaForm= “05/28/2021” the filter works ok, but with dates on june, it fails.

I got the first issue when the robot filtered:
[ReceivedTime] >= ‘06/01/2021’ AND [ReceivedTime] <= ‘05/31/2021’


@Ana_Blanco - Please check this…without time it is fetching with certain time limits that’s why you didn’t get any results…In my case I got 8…as soon as I added the time it started giving me perfect count…

Without Time


Here’s how I added my Datetime code

"[ReceivedTime] >= '"+ new DateTime(2021,06,09,00,01,00).ToString("MM/dd/yyyy HH:mm") +"' AND [ReceivedTime] <='" +new DateTime(2021,06,10,23,59,00).ToString("MM/dd/yyyy HH:mm")+"'"

and I got the same Result…with 22 emails fetched…

You can replace it two string variables in the above code by using the same datetime code with .tostring.

Hope this helps…

1 Like

Thanks! @prasath17
It was very useful, I could solve the issue!!
Using .tostring instead of toshortdatestring, as I was doing it.
Best regards!!


Ana KBS.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.