Date formatting issue

Hi all,

I’m currently passing a date through into a xaml, as an object. Let’s say it’s going in as “6/03/2020” (which is 6th March 2020)

The “in” argument (which is DateTime) currently converts it with this line ‘CDate(row(“Invoice Date”).ToString)’

When it gets into the xaml, it appears as ‘03/06/2020 00:00:00’

So it’s converted it into a datetime, which is fine.

Inside this xaml, the end result I want it to look like is ‘06032020’, but it has to recognise it as being 6th March 2020, because I want to also -31 days off this.

Any thoughts?

@MattWW
can you check following (in case of 2019.xx version is in use breakpointing and playing within the watch panel is recommended)

yourDateTimeVar.toString(“ddMMyyyy”)

When it gets into the xaml, it appears as ‘03/06/2020 00:00:00’

is it a typo as it is 3rd June? Otherwise take control on parsing with the dateTime.Parse or ParseExact function

Instead of CDate, please use DateTime.ParseExact to preserve the date format.

dtObject = DateTime.ParseExact(yourstring,"D/MM/YYYY")

For converting into 06032020 -> strFormat = dtObject.ToString("DDMMYYYY")

To minus 31 days, dtNew = dtObject.AddDays(-31)

Regards,
Karthik Byggari

Yes, definitely 3rd of June… When I look in the locals panel, it has the date details and the month is ‘6’.

dtObject = DateTime.ParseExact(yourstring,“D/MM/YYYY”)

yourstring? I need to put a variable in there tho, will that work?

give a try on
DateTime.ParseExact(yourDateStringVar, “d/MM/yyyy”, CultureInfo.InvariantCulture)

yourDateStringVar is a string variable holding the date info

Ensure System.Globalzation is added to the imports (right, variables tabs - imports)

Yeah I do have System.Globalization added.

Please take a look at the attached xaml… This is as close I can get to what I actually have.

Please see what can be done… I need the output date to be ‘06032020’
datetest.zip (13.6 KB)
I can add the ‘adddays(-31)’ later

Team,

Try this
for in_date argument value: Date.ParseExact(datevar, “d/M/yyyy”, System.Globalization.DateTimeFormatInfo.InvariantInfo)

and to display it in_Date.ToString(“ddMMyyyy”)

@MattWW

have a look here: