-1 day from string?

I have variable start date as string = 27/06/2021

If I want to -1 date from 27/06/2021

output : 26/06/2021 (string)

Please guide me about it.

first Convert that string to datetime format:
Dt_date= DateTime.ParseExact(“27/06/2021”,“dd/MM/yyyy”,System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)

out_date = Dt_Date.AddDays(-1).ToString(“dd/MM/yyyy”)

this will give you -1 day

Hi @fairymemay

Please try this also,

Cdate(yourvariable).AddDays(-1).Tostring(“dd/MM/yyyy”)

or

Convert.ToDateTime(yourvariable).AddDays(-1).Tostring(“dd/MM/yyyy”)

Thanks

1 Like

@prasath_S It error as below.
testtt.xaml (12.8 KB)

Please guide me for solve it.

testtt.xaml (14.5 KB)

can you check

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.