Forum Discussion
- Philip_BairdCommunity Expert
Hi Mamatha, the behaviour you are describing is consistent with the documentation for the aqDateTime.Time() method, i.e
"In JScript or DelphiScript, if you try to output the time returned by the Time method as a string, conversion takes place and the time is outputted in the day/month/date/time/year format. For example, this occurs if you use the following code to post the current time to the test log:"
function Test()
{
Log.Message("Time is" + aqDateTime.Time());
}
"To avoid such a conversion, you need to explicity specify the format in which time should be displayed. For example, you can use the following code:"
function Test()
{
Log.Message("Time is" + aqConvert.DateTimeToFormatStr(aqDateTime.Time(), "%H:%M:%S"));
}
If you wish to get an accurate date/time value, you should use the aqDate.Now() method
Regards,
Phil Baird - marinFrequent ContributorHello Mamatha,
according to TC manual this is the cause:
Here the description of method:
"...
Declaration
The method has the following parameter:
D
The date/time value to be converted to a string. If the date part of the value is missing, it is assumed to be the “zero date”, December 30, 1899. If the time part is missing, it is not included in the resulting string.
..."
As you are using aqDateTime.Time() to fetch the time value only, there will be only time part there (see attached image and look in manual of description of aqDateTime.Time()).
This is why it will be the 30/12/1899 assumed as "zero date" for conversion method aqConvert.DateTimeToStr().
Hope this helps,
Regards,
Marin
- Philip_BairdCommunity Expert
Apologies, that should read aqDateTime.Now() not aqDate.Now()
Phil - makulaOccasional ContributorHi Phil,
I know the method you have mentioned to format the date/time to string. The thing is when we use aqConvert.DateTimeToStr(aqDateTime.Today() )it returns current date, only date is logged in log file without any explicit format [aqConvert.DateTimeToFormatStr(aqDateTime.Today(), "%m/%d/%y"));] but when we use aqConvert.DateTimeToStr(aqDateTime.Time()) why only time is not returned. Hope you got my point. Hope the image attached gives you info about what am I asking.
the Jscript used is :
Log.Message('Current date and time is '+aqConvert.DateTimeToStr(aqDateTime.Now()));
Log.Message('Current time only '+aqConvert.DateTimeToStr(aqDateTime.Time()));
Log.Message('Current date only '+aqConvert.DateTimeToStr(aqDateTime.Today()));
Thanks,
Mamatha - makulaOccasional ContributorThank You!! :-)