Writing date in Wrong Format

Hii,

My Excel sheet column is having date in US format but when my BOT after Reading the excel writes it into Webpage TextField it is Writing in Indian Format with time as 00:00:00 which i not there in excel sheet ,it only has date in US Format.webpage is throwing error.
My UiPath is inside citrix Environment.

Please help

Hi,

which is your webpage expected format, Indian format or US format?

US Format

Hi,

Get your date from the excel as string and convert it as date in assign activity as below

Assign to a date variable: Convert.ToDateTime(dt.Rows(0)(“YourDate”).ToString).Date

Then while feeding it in your website convert your date as below

DateTime.ParseExact(convertedDate.ToString(“MM/dd/yyyy”), “MM/dd/yyyy”, Nothing).ToString(“dd-MM-yyyy”)

2 Likes

while type into date into field define date format which ever you want

example: date.tostring(“dd/MMM/yyyy/hh/ss”)

i am extracting it as row(2).tostring(“yyyy-mm-dd”) but it is throwing an error that implicit conversion not allowed from string to int.

Try like this,

convert the table value first to date datatype
Convert.ToDateTime(row(2)(“YourDate”).ToString).Date

then convert it to your target format as below
DateTime.ParseExact(convertedDate.ToString(“MM/dd/yyyy”), “MM/dd/yyyy”, Nothing).ToString(“yyyy-mm-dd”)

i can´t give any specific date in YourDate as My Bot will be extracting the Highest date from the excel column…i.e. it can 30 or 31

then you will get the highest date as a string right, convert that to date then proceed the second step

Hi ,
I have stored my Highest date as

MaxDate=readDT.AsEnumerable().Max(Function (a) DateTime.Parse(a.Item(“Trade Date”).ToString)).ToString

Assign Activity:

Date dateValue = Convert.ToDateTime(MaxDate.ToString).Date

then convert it to your target format as below
DateTime.ParseExact(dateValue .ToString(“MM/dd/yyyy”), “MM/dd/yyyy”, Nothing).ToString(“yyyy-mm-dd”)

date datevalue is???

create a variable as dateValue with DateTime Datatype.

Share your max date value and your desired format, it will be easy to understand

for converting it into target format i again need to take a variable in assign as datetype
and pass it like this
finaldate=DateTime.ParseExact(dateValue .ToString(“MM/dd/yyyy”), “MM/dd/yyyy”, Nothing).ToString(“yyyy-mm-dd”)

Hi,

Yes, but If you are using Type Into activity then you can do the final conversion inside that without having another variable ‘finalDate’. Its not required.

the above working solutions converts the date as below

Input Max Date : 06/18/2018
Final Converted Format : 2018-06-18

it converted but output should be 2018-06-12
but BOT is Writing 2018-00-12
Is it because my UiPath and webpage both are in citrix??

DateTime.ParseExact(dateValue .ToString(“MM/dd/yyyy”), “MM/dd/yyyy”, Nothing).ToString(“yyyy-MM-dd”)

in the format change mm to MM

use get date fields activity then give input of your date , define the variables like dd , mm, yyyy then finally construct in required formate