Choose Language Hide Translation Bar
Highlighted
JTennyson
Community Trekker

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!

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
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

0 Kudos
7 REPLIES 7
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
0 Kudos
JTennyson
Community Trekker

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.

0 Kudos
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

0 Kudos
JTennyson
Community Trekker

Re: Date Time issue

yes always mm/dd/yy hhmm

0 Kudos
txnelson
Super User

Re: Date Time issue

See my edited previous response

Jim
0 Kudos
JTennyson
Community Trekker

Re: Date Time issue

Thanks!

 

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

0 Kudos
JTennyson
Community Trekker

Re: Date Time issue

Works perfectly!

 

Thanks for the really quick response!

 

Joe

0 Kudos