Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
JTennyson
Level I

Date Time issue

I have a character-based date time field which is exported from an electronic health record which is in the syntax:

mm/dd/yy hhmm

I need to convert this to a usable date-time field.

I have found solutions for converting hhmm alone to JMP-acceptable time.  How do I get this entire field converted?

I am very new to JMP and have no code writing experience or even basic knowledge.  I can cut and paste a solution to the right place.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Date Time issue

I need an additional piece of information......are the time fields always 4 numbers......0101 etc.?  Or if not, how would 0101 be specified?

 

Once again I will assume....that if the seconds are always a 2 digit field, the following script can be run to add in the ":" between the minutes and seconds.  And then you can apply the suggestion from my first response.  I am using the column reference of :DateTime as the name for your column that has the date/time values.  Just change it out for the actual name of the column......Make sure you keep the ":" preceding the column name

Names Default To Here( 1 );
dt = Current Data Table();

For Each Row(
	:DateTime = Substr( :DateTime, 1, Length( :DateTime ) - 2 ) || ":" ||
	Right( :DateTime, 2 )
);
Jim

View solution in original post

7 REPLIES 7
Highlighted
txnelson
Super User

Re: Date Time issue

Right click on the header for the column and select Column Info

Change the Data Type from character to numeric

Change the Modeling Type that will now display, from Nominal to Continuous

Click on the Format down arrow and select "Time==>m/d/y h:m"

Click on Apply

 

Your dates should be converted from character to numeric

 

I am making one assumption, and that is that your hhmm actually has a delimiter between them, such as hh:mm

If it is truely hhmm with no separation, then a different approach will have to be used.  Respond back on your success, or if there are issues.

 

Jim
Highlighted
JTennyson
Level I

Re: Date Time issue

Actually - that assumption is the issue - no delimiter.  Found the above process before.  Also your post about how to convert hhmm to hh:mm, but don't know how to apply to the field with the date infront of it.

Highlighted
txnelson
Super User

Re: Date Time issue

I need an additional piece of information......are the time fields always 4 numbers......0101 etc.?  Or if not, how would 0101 be specified?

 

Once again I will assume....that if the seconds are always a 2 digit field, the following script can be run to add in the ":" between the minutes and seconds.  And then you can apply the suggestion from my first response.  I am using the column reference of :DateTime as the name for your column that has the date/time values.  Just change it out for the actual name of the column......Make sure you keep the ":" preceding the column name

Names Default To Here( 1 );
dt = Current Data Table();

For Each Row(
	:DateTime = Substr( :DateTime, 1, Length( :DateTime ) - 2 ) || ":" ||
	Right( :DateTime, 2 )
);
Jim

View solution in original post

Highlighted
JTennyson
Level I

Re: Date Time issue

yes always mm/dd/yy hhmm

Highlighted
txnelson
Super User

Re: Date Time issue

See my edited previous response

Jim
Highlighted
JTennyson
Level I

Re: Date Time issue

Thanks!

 

Have to go in for an evening sahift.  Will apply tomorrow

Highlighted
JTennyson
Level I

Re: Date Time issue

Works perfectly!

 

Thanks for the really quick response!

 

Joe

Article Labels

    There are no labels assigned to this post.