vaishali
(vaishali)
1
Hi All,
I have variable in datetime format - 2019 12 01
I need to get the date alone like 01
So variable. Day = last day
Now I need to get the pervious date of the particular day
I have mentioned as( last day-1)
But I getting an error as un representable date
Can any one plz help to fix the error
1 Like
Hello @vaishali ,
Please try to get the previous day, not by using last day-1.
Use something like:
yourdate.AddDays(-1)
Source: https://docs.microsoft.com/en-us/dotnet/api/system.datetime.adddays?view=net-6.0
Please let us know if other info is needed
Thank you!
Best regards,
Marius
Hey @vaishali
I hope the attached sequence helps you.

DateConverter.xaml (5.0 KB)
Gokul001
(Gokul Balaji)
4
Hi @vaishali
Try this below expression
DateTime.ParseExact(“Input String”,(“yyyy MM dd”),Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“dd”)
Result → 01
Refer the thread for more information
Regards
Gokul
vaishali
(vaishali)
5
Hi Marius,
I have datelast - 2019-12-01 datetime
To get the month alone _datelast.month int32
Year- to get the current year datetime.now.year int32
To get the date lastday - datelast.day into
But the condition is I need to get the perivou date if I mention datelast.adddays(-1)
Getting an error canny assign tye date.time to system.int32 in assign
Please help to resolve this
Hi @vaishali ,
To get the previous day try using this:
DateTime.ParseExact(“2019 12 01”,“yyyy MM dd”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“dd”)
Thanks
Hi!
Try like this:
Previous Day:
Cdate(str_Date).AddDays(-1).ToString("dd")
Current month and previous Day:
Cdate(str_Date).AddDays(-1).ToString("dd/MM")
Previous Month and Day:
Cdate(str_Date).AddDays(-1).AddMonths(-1).ToString("dd/MM")
Current Year and previous Day:
Cdate(str_Date).AddDays(-1).ToString("dd-yyyy")
Only year:
Cdate(str_Date).ToString("yyyy")
Reference:

Regards,
NaNi
2 Likes
Gokul001
(Gokul Balaji)
8
Hi @vaishali
Convert into integer to get the pervious date
CInt( DateTime.ParseExact(“Input String”,(“yyyy MM dd”),Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“dd”))
Regards
Gokul
Gokul001
(Gokul Balaji)
9
Hi @vaishali
Use Assign activity
LHS - Create an variable
RHS - Below condition
Convert into integer to get only Month
CInt( DateTime.ParseExact(“Input String”,(“yyyy MM dd”),Globalization.CultureInfo.InvariantCulture).ToString(“MM”))
Convert into integer to get only Year
CInt( DateTime.ParseExact(“Input String”,(“yyyy MM dd”),Globalization.CultureInfo.InvariantCulture).ToString(“yyyy”))
Hope it will works
Regards
Gokul
3 Likes
system
(system)
Closed
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.