Writing date in Wrong Format


#1

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


#2

Hi,

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


#3

US Format


#4

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”)


#5

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

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


#6

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.


#7

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”)


#8

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


#9

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


#10

Hi ,
I have stored my Highest date as

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


#11

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”)


#12

date datevalue is???


#13

create a variable as dateValue with DateTime Datatype.

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


#14

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”)


#15

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.


#16

the above working solutions converts the date as below

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


#17

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??


#18

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

in the format change mm to MM


Change date from excel
#19

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