Hi,
I want to convert Julian date to Calendar date in UiPath, specially through assign activity.
Anyone knows how to convert it?
For e.g. I have Julian date : 118072 and it’s calendar value is 13-03-2011 00:00.
Any help would be appreciated.
Thanks,
Shantanu
Hi THIRU_NANI, could you please elaborate more? I’m not getting it, its just Class, but how to use it? an explanation through example would be great help.
Hi
Hope the below steps would help you resolve this
Say you have your input in a string variable named Strinput
Now use a assign activity like this
int_date = 2000+Convert.ToInt33(Strinput.Substring(1,2))
Int_date is of type int32
One more assign activity
int_year = Convert.ToInt32(Strinput.Substring(4))
Then final assign activity like this
stroutput = Datetime(int_year,1,1).AddDays(int_date-1).ToString(“dd-MM-yyyy hh:mm”)
Cheers @Shantanu_More1
Hi Palaniyappan,
I’m trying your solution. But it’s saying “ToInt33 not a member of system.convert”? even though int_date is set to int32. How to resolve this?
Oh sorry that’s a typo
It’s ToInt32
@Shantanu_More1
Yeh, and one more typo, int_days should be int_date right?
and I have made variable strouput as System.DateTime. But I’m getting error : ‘Datetime’ is type and can’t be used an expression. For the last assign activity.
That’s right my bad
Refer this
Where stroutput is variable of type string
Not Datetime
@Shantanu_More1
Hi, I’m using stroutput as a ‘string’ but the same error. Could you please advise?
Not able to find AddDays in expression.
In case if you have zip file of working code, please share.
Thanks,
Shantanu
1 Like
Aah got it
We need to add New before Datetime like this
stroutput = New Datetime(int_year,1,1).AddDays(int_date-1).ToString(“dd-MM-yyyy hh:mm”)
Stroutput is string variable
Cheers @Shantanu_More1
Hi, I tried this, now it’s not showing any error, but it’s giving wrong output.(wrong calendar date)
I have attached the zip file of the code for your reference.
I have taken julian date as "118072 " and it’s calendar date it coming as “10-07-0077 12:00”.
Thanks,
Shantanu
JuliantoCalendar.zip (2.2 KB)
Hi,
You able to debug my code?
Given approach giving wrong result.
@Parth_Doshi @Pablito @loginerror
If you have any idea, please assist.
Thanks,
Shantanu
Dear @Palaniyappan ,
I have similar issue and tried the output as mentioned above in the above conversation.
I have the dates in the excel column as show in screen shot below. When I check the format it is in custom and in en-US format .
When I read range then the date get converted to a number.
Ex: 24-Jan-2022 equivalent number in data table is 44585
This is the output that I received
Appreciate your feedback as always.
Regards,
Manjesh
ppr
(Peter Preuss)
February 4, 2022, 3:31pm
14
@manjesh_kumar
looks more like an OADate
1 Like
I recently came across the scenario, Placing the solution for reference.
Assign a Int32 variable (Eg: JulianDate) with your Julian date value (Eg: 2460473)
JulianDate = 2460473
Assign a Datetime variable ( Eg: DTDateTime)
DTDateTime = DateTime.MinValue.AddDays(julianDate - 1721425.5)
Assign a string variable (Eg: Output) or any of your required format.
Output = DTDateTime.ToString(“MM/dd/yyyy”)
Input - 2460473
Output - 06/11/2024