Hello,
I am in need of some help from you FSQL veterans out there!
My overall goal is to convert an array of integers symbolizing the date and time from the plc, into a DateTime which the database can understand.
Iâm not too familiar with FSQL, but it seems I can do this using an Action Item to pass my values into a custom function on the database which returns the DateTime I needâŚ
Action Item: CalculateStartTime
Store Result to OPC Item: {StartTime}
dbo.DateTime({startTime_0}, {startTime_1}, {startTime_2}, {startTime_3}, {startTime_4}, {startTime_5});
Custom SQL Functions:
[code]create function Date(@Year int, @Month int, @Day int)
â returns a datetime value for the specified year, month and day
â Thank you to Michael Valentine Jones for this formula (see comments).
returns datetime
as
begin
return dateadd(month,((@Year-1900)*12)+@Month-1,@Day-1)
end
go
create function Time(@Hour int, @Minute int, @Second int)
â Returns a datetime value for the specified time at the âbaseâ date (1/1/1900)
â Many thanks to MVJ for providing this formula (see comments).
returns datetime
as
begin
return dateadd(ss,(@Hour3600)+(@Minute60)+@Second,0)
end
go
create function DateTime(@Year int, @Month int, @Day int, @Hour int, @Minute int, @Second int)
â returns a dateTime value for the date and time specified.
returns datetime
as
begin
return dbo.Date(@Year,@Month,@Day) + dbo.Time(@Hour, @Minute,@Second)
end
go[/code]
When I try to trigger the group I get this error:
08/07/09 11:29:50
Group Execution Error
Error executing item CalculateStartTime: ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near '2009'.
Does anybody see what I am doing wrong here? Also, if there is an easier way to do this please let me know.
Thank you for your help.
âHandledException