How to change to previous day

studio

#1

Hi there

how can i store the datefrom variable from the selected text and then minus 1 day before.

For this case, the date is 10 Nov, so after text scrapped and store as variable “datefrom”, how can i change the stored variable datefrom value from 10 to 09

Thanks


#2

Hello!

Try something like this:

DateTime.Parse(datefrom).AddDays(-1).ToString

Regards,


#3

Hi,

You will need some more steps, as DateTime.Parse cannot handle integers. However, you can construct a DateTime variable directly: if you capture the three parts of the date as e.g. dayFrom, monthFrom, yearFrom, all as Int32, then myDate = New DateTime(yearFrom, monthFrom, dayFrom).AddDays(-1), either in an Assign activity or as the variable’s default value, creates the DateTime you need.

If you subsequently need just the day value as integer, this is myDate.Day; see DateTime properties. If you need it precisely as “09” (a two-digit string), then this can be obtained as myDate.ToString("dd"); see custom format specifiers.


#4

Hi S Franzen

Thanks for the tips.

How should i use capture the “day” text in the browser UI?
Should i use screen scraping method and store it as a variable ?


#5

Hi there @kokleong_ong,
You can use the ‘Get Text’ Activity on each of the three fields, then parse them as a DateTime.

For example:

Get Text - Output = strDay
Get Text - Output = strMonth
Get Text - Output = strYear
If DateTime.TryParse(strDay & "/" & strMonth & "/" & strYear, Nothing) = False Then

* Throw 

End If
Assign - dtmDate = DateTime.Parse(strDay & "/" & strMonth & "/" & strYear).AddDays(-1)
Log - Message = "DateTest - " & dtmDate.ToString("dd/MM/yyyy")

The above will read each of the fields, attempt to parse the extracted values as a DateTime, upon failure, we’ll throw an exception (extracted values are not suitable), otherwise parse and log.


#6

Hi J Davey

Thanks for the tips.
Sorry im a bit confused, where should i put the code in?


#7

Select the From Date and convert it into datatable, It contain all possible date for the month…
Select some date in From Date, check the Selector, In that the date will be mention in the Selector.
Pass the variable to the selector for the (current Date - 1).


#8

Hi Mr JDavey

I have no success for this so far, do you able to provide a example workflow?

Thanks


#9

Hi there @kokleong_ong,
Can you provide more information regarding your issue?

Thanks,
Josh