How to input Current Date - 1 i.e. the previous Date in a date picker field in a Web Application


#1

I have automated search activity for a group of processes in a web application based on current date filter. How do I give the previous day’s date as filter so that when the EVA bot executes this process as a cron job at a particular time it always takes previous day’s date.


#2

DateTime.Today.AddDays(-1)


#3

Hi ,

Just elaborating Sandeep answer,

  1. Create an argument of type DateTime (PrevDay)
  2. Assign value using Assign activity
    PrevDay = DateTime.Today.AddDays(-1)
  3. You can get only the date string by PrevDay.ToShortDateString()
    In screen shot below i have printed it in output console. You can assign the same to an argument and use else where in your process


#4

Thanks. The above implementation is working and fetching me the previous day’s date. But it is fetching the date in “MM/dd/yyyy” format. The date picker field in the Web Application accepts date only in “dd/MM/yyyy” format. My flow is as below

  1. PreviousDateFrom = DateTime.Today.AddDays(-1) // DateTime

  2. PreviousDateTo = DateTime.Today.AddDays(-1) // DateTime

  3. PrevDayFrom = PreviousDateFrom.ToShortDateString() // String

  4. PrevDayTo = PreviousDateTo.ToShortDateString() // String

  5. PreviousDateFromInDdMmYy = Date.ParseExact(PrevDayFrom,“dd/MM/yyyy”,
    System.Globalization.DateTimeFormatInfo.InvariantInfo) // DateTime

  6. PreviousDateToInDdMmYy = Date.ParseExact(PrevDayTo,“MM/dd/yyyy”,
    System.Globalization.DateTimeFormatInfo.InvariantInfo) // DateTime

Step 5 & Step 6 is not working

How can I convert PrevDayFrom & PrevDayTo in “dd/MM/yyyy” format.

Thanks and Regards


#5

Hi ,

I could convert the previous days’ date from “MM/dd/yyyy” format to “dd/MM/yyyy” format . Below is the flow which worked for me.

  1. PreviousDateFrom = DateTime.Today.AddDays(-1)

  2. PreviousDateTo = DateTime.Today.AddDays(-1)

  3. PrevDayFrom = PreviousDateFrom.ToShortDateString()

  4. PrevDayTo = PreviousDateTo.ToShortDateString()

  5. PreviousDateFromInDdMmYy = DateTime.ParseExact(PrevDayFrom, “MM/dd/yyyy”, CultureInfo.InvariantCulture)

  6. PreviousDateToInDdMmYy = DateTime.ParseExact(PrevDayTo, “MM/dd/yyyy”, CultureInfo.InvariantCulture)

  7. PreviousDateFromInddMMyyyy = PreviousDateFromInDdMmYy.ToString(“dd/M/yyyy”, CultureInfo.InvariantCulture)

  8. PreviousDateToInddMMyyyy = PreviousDateToInDdMmYy.ToString(“dd/M/yyyy”, CultureInfo.InvariantCulture)

Thanks for your support