I need to check for a number of records of 1 database if an entry was created in another one. This is often done on the same second as in database 1, but not always. I could try searching a few more values, each one second later, if not found on the exact time.
This obviously means not only the last second gets one higher but at e.g. 15-1-2025 23:59:59 even the date changes.
Does anyone have some VO code that is handling this and willing to share that?
(Yes I know I can use X# for that as DateTime.AddSeconds(Double) takes care of this all. But the VO programs currently still running for clients will most likely remain VO programs and adding this method in my X# library called from VO usually means I have to go through a lot of troubleshooting first because of Side By Side errors or existing code which doesn't compile anymore in the new X#....I'll only do that if there's no other way).
Speaking of Side By Side errors: I've got one client who gets this error most first time she starts our VO program (using an X# lib, hence this error). She tries again and it starts without the error. The very same program always starts the first time on my system.
How can this be?
Dick
Does anyone have a function for VO to increase date/time per second
- ArneOrtlinghaus
- Posts: 418
- Joined: Tue Nov 10, 2015 7:48 am
- Location: Italy
Re: Does anyone have a function for VO to increase date/time per second
Hi Dick,
I have attached some functions. They are based on the "ANSI-Timestamp-Format" as it is used in the VO-SQL-Library:
YYYY-MM-DD HH:mm:SS
Basically the concept is to convert the timestamp string into an array with a VO date and seconds since midnight. Then something can added or substracted to the date or the seconds. Afterwards the two values can be transformed back to a timestamp string.
Arne
I have attached some functions. They are based on the "ANSI-Timestamp-Format" as it is used in the VO-SQL-Library:
YYYY-MM-DD HH:mm:SS
Basically the concept is to convert the timestamp string into an array with a VO date and seconds since midnight. Then something can added or substracted to the date or the seconds. Afterwards the two values can be transformed back to a timestamp string.
Arne
- Attachments
-
- timestampfunctions.txt
- (6.25 KiB) Downloaded 9 times
Re: Does anyone have a function for VO to increase date/time per second
Hello Arne,
Thank you very much, that looks promising. I do miss a few things however, only one I think I would need what you have there:
cTimeStamp := Left(DToCSQLBase( dDate ) + " " + cTime, 19)
(+MsgInternalErrorlimited + trimcrlf; one shows an error message and I think the 2nd removes CRLF from a string.
Could you upload DToCSQLBase as well?
Dick
Thank you very much, that looks promising. I do miss a few things however, only one I think I would need what you have there:
cTimeStamp := Left(DToCSQLBase( dDate ) + " " + cTime, 19)
(+MsgInternalErrorlimited + trimcrlf; one shows an error message and I think the 2nd removes CRLF from a string.
Could you upload DToCSQLBase as well?
Dick
- ArneOrtlinghaus
- Posts: 418
- Joined: Tue Nov 10, 2015 7:48 am
- Location: Italy
Re: Does anyone have a function for VO to increase date/time per second
Hi Dick,
here are the missing functions. The MsgError-Functions can be substituted or left away.
func DToCSQLBase(dDate as date) as string
local nDay as usual // usual wegen Problemen mit StrZero
local nMonth as usual
local nYear as usual
nDay := Day(dDate)
nMonth := Month(dDate)
nYear := Year(dDate)
return Str(nYear, 4) +"-" + StrZero(nMonth, 2)+"-"+ StrZero(nDay, 2)
function TrimCRLF (cText := nil as usual) as string
local n, nOrigin as int
if IsNil (cText)
return ""
endif
n := nOrigin := int(SLen(cText))
do while n >= 1 .and. ;
InList (SubStr3 (cText, dword(n), 1), " ", _chr(ASC_CR), _chr(ASC_LF))
n-=1
enddo
if n == nOrigin
return cText
elseif n = 0
return null_string
else
return SubStr3 (cText, 1, dword(n))
endif
Arne
here are the missing functions. The MsgError-Functions can be substituted or left away.
func DToCSQLBase(dDate as date) as string
local nDay as usual // usual wegen Problemen mit StrZero
local nMonth as usual
local nYear as usual
nDay := Day(dDate)
nMonth := Month(dDate)
nYear := Year(dDate)
return Str(nYear, 4) +"-" + StrZero(nMonth, 2)+"-"+ StrZero(nDay, 2)
function TrimCRLF (cText := nil as usual) as string
local n, nOrigin as int
if IsNil (cText)
return ""
endif
n := nOrigin := int(SLen(cText))
do while n >= 1 .and. ;
InList (SubStr3 (cText, dword(n), 1), " ", _chr(ASC_CR), _chr(ASC_LF))
n-=1
enddo
if n == nOrigin
return cText
elseif n = 0
return null_string
else
return SubStr3 (cText, 1, dword(n))
endif
Arne
Re: Does anyone have a function for VO to increase date/time per second
Thank you very much. This will be very useful for what I want to check.
One small thing I was wondering: how can
compile for you (compiler says Bad statement syntax 51402)
I changed it to
and then it works.
Dick
One small thing I was wondering: how can
Code: Select all
RETURN (INT)fret
I changed it to
Code: Select all
RETURN Integer(fret)
Dick