PDA

View Full Version : Use Time from iTime as time coordinate for AddObject



amit.aggrawal321
02-16-2015, 02:43 PM
In my VTL script I have time coming from iTime function as "2015-02-16 16:00" (without quotes). I want to use this time as one of the time coordinate for AddObject function. However AddObject time coordinate expects the time in "16/02/2015 16:00:00" format. How can I change the format to what AddObject expects?

Is there any direct way?

Thanks,
Amit

Hassan-HS
02-16-2015, 03:07 PM
Hello Amit,

Sure you can use "Replacement()" vb built in function.

Please check the following sample code



Public Sub main()


Dim barNumber
Dim result
barNumber=2
result=iTime ("EUR/USD",PERIOD_D1,Clng(barNumber))
MsgBox result
MsgBox Replace (result,"-","/")






End Sub

amit.aggrawal321
02-17-2015, 05:56 AM
Thanks sir for the reply. However it is not just the replacement of - to /

Datetime format that iTIme is returning is YYYY-MM-DD HH:MM and the one that AddObject expects is DD/MM/YYYY HH:MM:SS

Isn't there any direct conversion function or any time/date formatting function ?

Moreover when both the parameter deal with date/time, should not there be common convention (format) ?

Let me know your views.

Thanks,
Amit

Hassan-HS
02-17-2015, 03:09 PM
Hello Amit,


You can develop your own function (Split then Concatenate) to make this conversion.