cancel
Showing results for 
Search instead for 
Did you mean: 

Split Date from Datetime value

RohanGoswami1
Level 3
hi I need little help in splitting the date from datetime value. Previously I was doing like this
Datetime = 19/09/2022 17:44:17
date = left(Datetime, 10)  = 19/09/2022

Now this is not working as 
Datetime = 1/2/2023 17:44:17
date = left(Datetime, 10)  = 1/2/2023 1

Any efficient way to do this manipulation?
8 REPLIES 8

Denis__Dennehy
Level 15
Hello Rohan.   What you want is to use the FormatDate function.   Another thread on this forum has the answer to what you want:  How to convert date format (dd/mm/yyyy) to (mm/dd/yyyy) | Blue Prism Product

The calculation UI has great help for building functions,  I suggest maybe spending time looking at all the functions available under 'Date' as the answer was there for you to discover.  There is also good help in the Blue Prism online help for Calculations and Decisions.

MichealCharron
Level 8
If you are just trying to convert a DateTime value to a Date value, you can use the ToDate() function. The ToDate() function works both with DateTime data items and Text data items (as long as the string is in the proper DateTime format).
Micheal Charron
RBC
Toronto, Ontario
Canada

EslamGhandour
Level 4
As Michael mentioned, using the ToDate() will be your way to go. However, one of the main things to consider working with that, is that it works according to the format of date on your pc. Which means if the time on your pc is mm/dd/yyyy and the value you path to that function is dd/mm/yyyy, it will not be providing you accurate values and it might be breaking when the mm value will be more than 12 as there are only 12 months. Work with that in mind and you'll be safe to go.

Hi

You can use FormatDate, ToDate but the problem is Input Format => MM/dd/yyyy or else PFB you'll get this error

35232.png

So you can try this, It's effective  => Trim(Left("1/2/2023 17:44:17", InStr(Trim("1/2/2023 17:44:17"), " ")))
Thanks Prasanth Software Engineer | RPA Developer

Soumya21
Level 6
Hi @RohanGoswami1

Check this expression will it work for you
Replace(Replace("1/2/2023 17:44:17",Right("1/2/2023 17:44:17",8),"")," ","")​

Thanks,
Soumya

35233.png


ÖzençGezgin
Level 4
Yes. Very efficient way 🙂

Do not use any formula. Only use data item...
Expression section: [Datetime]
Store Result in section: date
35235.jpg

ÖzençGezgin
Level 4
Hi Rohan,

Did you try my solution?

RohanGoswami1
Level 3
For my requirements I am using the FormatDate and it working Fine. Thanks for all the responses, Appreciate it.