cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Seconds portion of time along with date using Format function

VijayendraRao
Level 3
Hi,

In the attached screenshot, the yellow highlighted portion ALWAYS shows the seconds as 00. Wherein I would like to display the actual seconds of the LocalTime().
Please note, when just the LocalTime() is printed, it correctly displays the seconds, but NOT when combined with the Today() and when the Format function is used.

I'm aware we can separately output Today and LocalTime via different Calc stages and then concatenate into a single Data Item. But is there a way to do the same in a single Calc stage just by formatting the date and time together to show the "seconds" part of the time too?


Expression used in below screenshot is FormatDateTime(Today() & " " & LocalTime(), "dd-MM-yyyy HH_mm_ss") 
20336.jpg


Thanks.

------------------------------
Vijay

------------------------------
Vijay
1 BEST ANSWER

Best Answers

Hi Vijay

It seems you can't use LocalTime as text because the seconds portion is lost during the cast that occurs with concatenation (&), Replace or any other text function. This may be a bug, I'm not sure - the support team may be able to help https://portal.blueprism.com/customer-support/how-can-i-get-help-customer-support

As a work around, try something like the following. It's convoluted but it may help you: FormatDateTime(Now()+(LocalTime()-UTCTime()), "ss")




------------------------------
John Carter
Professional Services
Blue Prism
------------------------------

View answer in original post

9 REPLIES 9

John__Carter
Staff
Staff
It seems when the result of LocalTime() is cast to text, the seconds are lost. Try the expression ""&LocalTime() to see what I mean.

------------------------------
John Carter
Professional Services
Blue Prism
------------------------------

Hi John,

Thank you for the response.

The expression  ""&LocalTime() shows as 08:35
whereas LocalTime() shows as 08:35:46

None of these would suit my project requirements.
My intention is to use the date as well as time with seconds in a file name because slash / and colon : cannot be used in file name I want to use it with hyphen and underscores as below.

Format: dd-mm-yyyy HH_MM_SS
Output: 25-05-2020 08_35_46 

1. This is not achievable through the FormatDateTime function (due to which this thread has been opened).

OR

2. Also the below does NOT work as it again excludes the seconds
Replace(LocalTime(), ":", "_")

OR

3. First store LocalTime() to a Time DataItem
and then use Replace([myTime],":", "_") on that DataItem throws a 'Text cannot be interpreted as a Time' error message.
Using ToTime conversion also throws an error.


It was preferable to use a single line of FormatDateTime function.
But since neither of these 3 options work what are the other options you would like to suggest?

Also maybe you might want to report the bug about FormatDateTime function
Or let me know if there is a way to report a bug.

------------------------------
Vijay
------------------------------
Vijay

Hi Vijay

It seems you can't use LocalTime as text because the seconds portion is lost during the cast that occurs with concatenation (&), Replace or any other text function. This may be a bug, I'm not sure - the support team may be able to help https://portal.blueprism.com/customer-support/how-can-i-get-help-customer-support

As a work around, try something like the following. It's convoluted but it may help you: FormatDateTime(Now()+(LocalTime()-UTCTime()), "ss")




------------------------------
John Carter
Professional Services
Blue Prism
------------------------------

MattPalmer
Level 5
I use the following calculation to put a time stamp into a file name:  FormatDateTime(Now(),"yyyy_MM_dd - hh_mm_ss")

------------------------------
Matt Palmer
Business Process Specialist
Chesapeake Energy
America/Chicago
------------------------------

Thank you John and Matt.

Since the Blue Prism time is in UTC, Now() gives the output in UTC time.

So have made the below modifications and this serves the purpose for a passing the local date and time to a file name.

FormatDateTime(Now()+(LocalTime()-UTCTime()), "dd-MM-yyyy hh_mm_ss")

Will check out the link on reporting a bug.

Thanks.

------------------------------
Vijayendra Rao
Technical Lead
T-Systems ICT India Pvt. Ltd.
Asia/Kolkata
------------------------------
Vijay

Dear all,

UPDATE: As an FYI to anyone who comes up on this thread-

I have reported the bug to Blue Prism and they have agreed to fix it in the next release of Blue Prism.
It will be added in the future release notes with reference as BG-1533 

Until then the below line can be used as workaround
FormatDateTime(Now()+(LocalTime()-UTCTime()), "dd-MM-yyyy hh_mm_ss")

Thanks.

------------------------------
Vijay
------------------------------
Vijay

Thank You Vijayendra 

thats exactly what im searching for 🙂



------------------------------
Martin Schirmeister
Business Analyst
neue leben AG
Hamburg
------------------------------

Cheers Martin! 🙂

Are you saying that the original bug that I reported on 22/5/20 is not working for you because it is not yet fixed in any of the new releases?

------------------------------
Vijay
------------------------------
Vijay

i cant say exactly - i need a time combinated with Today() and LocalTime() - but the seconds were missing.
The workaround FormatDateTime(Now()+(LocalTime()-UTCTime()), "dd-MM-yyyy hh_mm_ss") works as i need it 🙂


------------------------------
Martin Schirmeister
Business Analyst
neue leben AG
Hamburg
------------------------------