変数で取得した日付を分割したい

こんにちは。初めて投稿させていただき、初心者のものです。

エクセルから日付を取得して、
年、月、日を分割して、
Webサイトにそれぞれ貼り付けをしたいです。

エクセルから変数で取得すると、Uipathの場合、変数Aのように取得されました。
エクセル:2019/5/31
変数A:05/31/2019 00:00:00

どのようにばらばらに年月日をそれぞれ取得したらよいのかわからないので
教えていただけますでしょうか。
いろいろ調べてみたのですが、

代入のパーツで今日の日付だと成功するのですが、
年=now.year.Tostring
月=now.month.Tostring
年=now.day.Tostring

といれると今日の日付で年は「2019」、月は「06」、日は「20」を取得してくれるのですが、変数からだとどのようにしたらよろしいでしょうか、教えてください。

どうぞよろしくお願いいたします。

1 Like

Hi @threetenthree
Welcome to uipath community buddy

Use this in three assign activities like
if
String variableA = “05/31/2019 00:00:00”

String Out_month = Split(variableA,“/”)(0).ToString // gives 05 as a string value
String Out_day = Split(variableA,“/”)(1).ToString // gives 31 as a string value
String Out_year = Split(Split(variableA,“/”)(2).ToString," ")(0).ToString //gives 2019 as a string value

Kindly try this and let know buddy
Cheers @threetenthree

1 Like

こんにちは

まずは変数の型の概念を正しく理解することがベターなのですが
別解として、DateTime型の変数(仮にdt)を用意して、代入アクティビティで

dt = DateTime.ParseExact(変数A,“MM/dd/yyyy HH:mm:ss”,nothing)

としておくと
dt.Year や dt.Month などで値を取得できます。

1 Like

Thank you for your giving me a hand !!
Thanks to you my task has solved the problem !!

1 Like

回答どうもありがとうございます!
Winactorより概念が難しいですね。覚えておくようにします!

Fantastic
Cheers @threetenthree

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