Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.

Log in or register to post/reply in the forum.

RealTime function

Otemohu Nov 30, 2017 07:32 AM

Hi all,

I'm currently want to create a variable based on the datalogger realtime.
My output format should be YYYYMMDDhhddss
If I'm using the RealTime function to get the nine variables linked to the time, ie YYYY, MM, DD, hh, mm, ss, micros, DOW, DOY and rearrange the output time as folowing :

Public rTime(9)
Public DesiredTime As String *17

Realtime (rTime)

DesiredTime = rTime(1) & rTime(2) & rTime(3) & rTime(4) & rTime(5) & rTime(6)

As it, I will get a output realtime that will be sometimes cut due to the presence of non zero front of value. Here is an example :

If time is 2017 12 01 15:09:27, I will get 201712115927 and no 20171201150927.

Do you have a quick solution without using long test to keep a zero when rtime <10?

All the best,

JDavis Nov 30, 2017 08:45 AM

I find it easier to use Status.TimeStamp(4,1) to get the timestamp as a string, then using the MID function to get the formatted pieces that you need.

The help for the syntax is listed in the help index under TableName.TimeStamp

Otemohu Nov 30, 2017 09:17 AM

I've tested this solution but get systematicaly a delay, typically 1.08 sec. I think I have to force the seconds to zero.

JDavis Nov 30, 2017 09:23 AM

Then go with your first approach, but use the FormatFloat instruction on each component of the timestamp to have the leading zeroes.

Otemohu Dec 7, 2017 01:35 AM

Ok I did it, thank you. I will ask another question on the forum regarding "time slicing" issue ?!?

ArtHeers Jan 4, 2018 12:31 PM

Another function introduced to help with this is sprintf(), which can be used more simply than Format Float, as with this example:

Public RT(9) As Long, RTStr As String

Log in or register to post/reply in the forum.