sumouse
(ChoboIT)
August 26, 2019, 3:16am
1
변경 전 데이트 형식을 변경 후 데이트 형식으로 바꾸는 방법이 궁금합니다.
언어를 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
Fine
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
samir
(Samir Mohite)
August 26, 2019, 4:53am
3
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
sumouse
(ChoboIT)
August 26, 2019, 5:47am
4
고맙습니다.
아래의 경우도 가능한가요?
September 2016 => 2016-09
해결 : DateTime.ParseExact(“September”, “MMMM”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM”)
system
(system)
Closed
August 29, 2019, 5:47am
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.