Recognize Time out of Date/Time String not according to Standard SPSS Format

Hello,

I have a date and time variable ‘Received’ written as follows: “01/09/2015-09:40:21″(string variable).

Using “Date/time wizard”, I can only create a variable containing the date. It does not recognize time, unfortunately I also need this.

I tried the following:

I used “Compute variable” with the subtract function in several ways, for instance CHAR.SUBSTR(Received,12,8), but then I get the message:

“Invalid combination of data types in an assignment. Character strings may only be assigned to string variables. Numeric and logical quantities may only be assigned to numeric variables. Use the STRING command to declare new string variables before assigning values to them or consider using the STRING or NUMBER function”

In “Compute Variable” I tried to use the STRING and NUMBER function such as test=STRING(Received, F4) without effect.

I replaced the /, : and – signs and repeated above methods, but that does not solve the issue.

Though little experienced with syntax, I tried the following afterwards:

ALTER TYPE Received (A19).

EXECUTE.

COMPUTE num = NUMBER(SUBSTR(Received,8,6),f4) .

EXECUTE .

Does not work.

Can you give advice how to get a variable that recognizes the time?

Related:

Do if/else if is returning blank values

I am trying to recode some data into a new variable. The data is found in 3 variables, named: EmotminusMeanE, PmotminusPmean and LmotminusmeanL. The data needs to be categorised so that every combination of negative/positive result is given a category. Here is the syntax:
DO IF (EmotminusMeanE 0 AND PmotminusPmean>0 AND LmotminusmeanL>0).
COMPUTE E_cat = 8.
ELSE IF (PmotminusPmean>0 AND LmotminusmeanL0 AND EmotminusMeanE 0 AND LmotminusmeanL>0 AND EmotminusMeanE 0 AND PmotminusPmean 0 AND PmotminusPmean>0 AND LmotminusmeanL0 AND LmotminusmeanL>0 AND PmotminusPmean

Related:

Creating a new variable: trying to recode different variables into one new variable. Have SPSS 25, and even though my input variables are all string, it won’t let me use the same name for output variables.

Creating a new variable: trying to recode different variables into one new variable. Have SPSS 25, and even though my input variables are all string, it won’t let me use the same name for output variables.

I have different variables which are string that I am trying to recode into one new variable (0,1). When I try the function of recode variables, it won’t let me give the same new variable name to more than one input variable even though the whole goal is to have them all recoded into this same new variable. Help!

Related: