How to Conveting DateFormat

변경 전 데이트 형식을 변경 후 데이트 형식으로 바꾸는 방법이 궁금합니다.
언어를 VB로 사용하고 있어요

검색 통해서 나온 방법들을 참고해서 아래와 같이 두 가지 사용을 해봐도
“String was not recognized as a valid DateTime.”
라는 에러만 나오고 있어요

Convert.ToDateTime(“Wed Jul 31 11:07:00 KST 2019”).Tostring(“dd-MM-yyyy HH:mm:ss”)

DateTime.ParseExact(“Wed Jul 31 11:07:00 KST 2019”, “dd-MM-yyyy HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture)

변경 전 : Wed Jul 31 11:07:00 KST 2019
변경 후 : 2019-07-31

1 Like


The issue was like the date string format is different with what we have mentioned in the ParseExact method
So if this is the input
In_str = “Wed Jul 31 11:07:00 KST 2019”

Then to get the out string of required date
—Use a assign activity
In_str = Split(In_str,” “)(5)+”-“+Split(In_str,” “)(1)+”-“+Split(In_str,” “)(2)

Then another assign activity

Out_str = DateTime.ParseExact(In_str,”yyyy-MMM-dd”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)

Cheers @sumouse

Hi @sumouse
dude, its becasue you didn’t mention date format correctly (Wed —> ddd & about timezone.)

try this you’ll get the output as you want it,

DateTime.ParseExact(“Wed Jul 31 11:07:00 KST 2019”, “ddd MMM dd HH:mm:ss ““KST”” yyyy”, System.Globalization.CultureInfo.InvariantCulture)

1 Like


아래의 경우도 가능한가요?

September 2016 => 2016-09

해결 : DateTime.ParseExact(“September”, “MMMM”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM”)

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