How do you get the date of the current day, or the day before?

#1

Hi,

How to get the date

How do you get the date of the current day, or the day before? Do you use powershell scripts and write to a file?

Is there an easier way?

Thx,
Marcio

How to add and subtract dates?
Filtering Excel files
#2

@marcio_jesus,

Thanks for sharing your case.

To get the current date, you can use the Constant Value action - https://kb.workfusion.com/display/RPAe/Variables#Variables-Date.1

Then convert Date to String (using Clipboard)

Afterwards, you can do some text operations with it - https://kb.workfusion.com/display/RPAe/Text
For example - https://kb.workfusion.com/display/RPAe/Text#Text-SubstringBetweenSubstringBetween

The Type Conversion support is planned to be introduced in the 1.1.9 release (December).

3 Likes
#3

Hi @azinchuk,

Thanks for the quick return!

Márcio

#4

Hey

I’m unable to write the constant variable (current date) into text and can’t figure out why.

Also is it possible to get the date from the day before? (current date) - 1

Thanks

#5

You cannot use date variable in Enter keystrokes action.
It should be converted to a string first. You can see how to do it in this post How to write current date in notepad

1 Like
Time zone conversion
#6

You can get the day before using data type conversion and text actions as shown below.

  1. Convert date to string and split the string variable.
    date-to-string

  2. Convert the day to number and subtract a day.

expression

  1. And convert number back to string and join strings.
    number-to-string

The resulting string will contain the date before the current date.

#7

Wow those are a lot of actions, eheh.

Thank you very much.

1 Like
#8

Good Morning
Alesia, Is there a reason you added the 0 behind the ${day} in action 8 constant value?

Thanks

#9

@goncalo_vascbE No specific reason, just so it will have the format 02/03/18.

#10

Alright, what about if the current date is day 1. Is it possible to get the last day from the previous month? This way will only subtract 1-1= day 0

1 Like
#11

Hi @goncalo_vascbE,

I had the same problem too. I have used the power shell of Windows System to generate this information in txt file: frowning:. I have to open the file to get the information.

I did not find a solution at the time, but would be great if the RPA make calculations with date.

#12

vote this feature

1 Like
#13

@goncalo_vascbE @marcio_jesus you can get the day before using this custom script

#14

Hi every one …
Actually i enter a date value in to a string variable (mm/dd/yyyy) in this format and always i enter a sunday date , from that date i want to calculate the all previous(upto monday) day dates. For example i am enter previous sunday date ie(05/12/2019) ok, so here i calculate the saturday date ,firday date thusday date and so on upto monday date.(05/11/2019,05/10/2019,05/09/2019,05/08/2019,05/07/2019,05/06/2019) this is saturday to monday date, so i am also calculate the date in this ways .

Please help me ,Thank you…

#15

In this case you just need to convert the string to a Date and then use on the scripts from the topic shared above

#16

Thanks for your suggestion,
But think is that how i used that in because i am new in rpa, can you explain me with example .
Please .

#17

Here it is

convert to date variable

calculate another date

#18

I try to execute same code for confirmation purpose but its showing error image ,

.

#19

Have you created a variable ‘friday_date’ that you use in the script?

You can read how to use custom actions and see some examples in the knowledge base
https://kb.workfusion.com/display/RPAe/Script+as+Custom+Action

#20

Yes i have create the variable ‘friday_date’ in the script.