Some data sets may contain time stamps in the format hh:mm:ss AM(PM), and it may be necessary to band these times together based on 24-hour time. For example, the analysis may require you to group respondents into 4-hour categories throughout the day. The software does not have a concept of time in the same sense as it has the concept of Date.
Technical details
Both examples of code below would be used in a JavaScript-Numeric variable. The examples will convert the values into hours 1-24, which facilitates grouping of the time frames.
Method - Using a time stored as text
This example assumes the time values are in format hh:mm:ss AM(PM).
//replace TIME with the name of your time variable stored as text
var _time_value = TIME;
//splits the time into individual numbers - assumes variable is format hh:mm:ss AM(PM) var _split_values = _time_value.split(":");
//takes the first number as the hour var _hour = parseInt(_split_values[0]);
//if in PM will add 12 hours to the hour value if (_time_value.indexOf("PM") > -1) _hour = _hour + 12 _hour
Method - Using a Date/Time variable
There is a built-in function to pull the hour off a Date/Time variable.
//replace date_variable with the name of your date/time variable
Q.Hour(date_variable)