Get current datetime for use in VAD?

Status
Not open for further replies.

millsey

Premier Customer
Joined
Dec 21, 2011
Messages
208
Reaction score
0
I need to get the current date and time as seen by the server for inclusion as a field in a SQL query.

I have tried

DATE()

as a javascript expression but it does not work and there is a line in the log file:
21:36:10.562|10832|(0):Error! Module '3CX.com.OSBjsi'. Error ID 501. errmsgReferenceError: DATE is not definedline1linetxttokentxt

I need to get this working, Ideally I would like to supply this date in a way SQL server can accept directly.

Millsey
 
Maybe it's better to get the current date and time into the SQL statement. The syntax depends on the server, for example for SQL Server you can use "GETDATE()", or for PostgreSQL you can use "now()".

Regards,
 
I actually need to find a way to get this working. Pulling the date and time from 3CX is important since it gives us a change to accurately match calls hitting the VAD with other data we use from the postgresql database.

I am already logging the datetime the SQL stored procedure is run but there are discrepancies between 3cx timing and the time the stored procedure is run.

What expression or command can I use to get the date and time into a string which I can include as a parameter int eh SQL statement?
 
Hi Millsey,

The following article explains how to set the current hour to a variable, using a javascript expression:
http://www.3cx.com/blog/voip-howto/javascript-3cx-vad/

You just need to work with the javascript expression. For example, "new Date()" returns a javascript date time object containing the current date time of the 3CX server. Here you have the reference of the Date object:
http://www.w3schools.com/jsref/jsref_obj_date.asp

There are different methods to convert it to a string, with different formats. For example, you could use the method "toDateString()" or "toISOString()", or any other method to convert the Date to string. That way, your expression will be for example:
new Date().toDateString()

Then you can pass the string variable as a parameter to your SQL query.

Hope the information helps.
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,322
Messages
591,882
Members
165,469
Latest member
footandankle.my3fcx.us