How to find Current day in Currentdatetime we get date and time not day
Hello @nutanved, you can use the .DayOfWeek property (https://robin-language.org/docs/robin-the-rpa-language/default-data-types/#datetime) to retrieve the current day from Date Time:
DateTime.Local DateTimeFormat:DateTime.DateTimeFormat.DateAndTime \ CurrentDateTime=> CurrentDateTime set CurrentDay to CurrentDateTime.DayOfWeek Console.Write Message: 'Today is '+CurrentDay
set CurrentDay to CurrentDateTime.DayOfWeek
if CurrentDay=‘Sunday’ or CurrentDay=‘Saturday’ then
Console.Write Message: “WeekEnd”
Console.Write Message: “WeekDay”
This is my code i want to print weekend if day is sunday or saturday otherwise weekday
but it throw below error
L5:3 Invalid type ‘DayOfWeek’ in comparison
@nutanved it seems that something prevents the .DayOfWeek property to be recognized as a Text type value.
Try this instead:
DateTime.Local DateTimeFormat:DateTime.DateTimeFormat.DateAndTime\ CurrentDateTime=> CurrentDateTime Text.CustomDateTimeToText DateTime: CurrentDateTime \ CustomFormat: 'dddd' Result=> CurrentDay Console.Write Message:CurrentDay if CurrentDay='Sunday' or CurrentDay='Saturday' then Console.Write Message: 'WeekEnd' else Console.Write Message: 'WeekDay' end
This is indeed a known bug in Robin SDK v0.9.1.
We have already fixed it and we will soon upload a new version.
Your script will work fine on the latest version.
For now you could use the workaround @jokoum provided.
I have also modified the title of the post and transferred it to the appropriate category.