Hi ,
I want to know the date format from a variable(String) which has value Example : “10/12/2020” or “20-JUN-2020” etc, Is there any approach to get the format of it?, before converting to date.
Thank you & Regards,
Nikhil
ppr
(Peter Preuss)
May 27, 2021, 11:17am
2
have a look on the different links for parsing multi formats
@gerlynn_lxy
have a look here:
Parsing_MultipleFormats_DTConfig.xaml (13.0 KB)
the fourth argument within the ParseExact working with date formats is missing
go eg for a
DateTime.ParseExact(row(0).ToString.trim, arrFormats, cultureinfo, DateTimeStyles.None)
where arrFormats = your DateFormats, cultureinfo is a prepared variable
for shortening the code just import the namespace as below:
[grafik]
@BalaM1510
the main building block is an array with formats:
[grafik]
which can be used
DateTime.ParseExact(YourDateString, arrFormats, YourCultureInfo, DateTimeStyles.None)
from your question it can be derived:
a column with date strings is the input for a dateTime.ParseExact
the conversion result will update the value within the column
LINQ could be used for this. But as we have to be prepared for conversion fails LINQ is less helfull for this due:
ALL or Nothing is converted
intran…
Checking in Advance if string is parseable we can do with tryParseExact (also with the arrFormats, handling multiple formats)
@icehouselux
use an assign activity:
leftside: check (Boolean)
Rightside:
DateTime.TryParseExact(yourDateTimeString, “yyyyMMddHHmmss”, CultureInfo.InvariantCulture, DateTimeStyles.None, Nothing)
ensure following:
[grafik]
1 Like
system
(system)
Closed
June 10, 2021, 11:00am
3
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.