cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
joann
Level IV

combine formula

Hi, could someone help me combine the 2 formulas below? The second one is simply minus the time of day part. Thank you.

 

----------------------------------------

 

New Column( "week start",
Numeric,
"Nominal",
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Formula(
If( Day Of Week( :WR_Date ) == 1,
(:WR_Date - In Days( Day Of Week( :WR_Date ) )) - In Days( 5 ),
(:WR_Date - In Days( Day Of Week( :WR_Date ) )) + In Days( 2 )
)
),
Set Selected
),
New Column( "Date[week start]",
Numeric,
"Nominal",
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Formula( :week start - Time Of Day( :week start ) ),
Set Selected
),

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: combine formula

I think you could also directly remove Time Of Day(:WR_Date) because the result of that if statement should have same hours, minutes and seconds as the :WR_Date column

 

Formula(
	If(Day Of Week(:WR_Date) == 1,
		(:WR_Date - In Days(Day Of Week(:WR_Date))) - In Days(5),
		(:WR_Date - In Days(Day Of Week(:WR_Date))) + In Days(2)
	) - Time Of Day(:WR_Date)
),
-Jarmo

View solution in original post

4 REPLIES 4

Re: combine formula

I'm doing this quickly, but I think this would work:

 

New Column( "Date[week start]",
Numeric,
"Nominal",
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Formula( ( If( Day Of Week( :WR_Date ) == 1,
(:WR_Date - In Days( Day Of Week( :WR_Date ) )) - In Days( 5 ),
(:WR_Date - In Days( Day Of Week( :WR_Date ) )) + In Days( 2 )
) )
 - 
Time Of Day( ( If( Day Of Week( :WR_Date ) == 1,
(:WR_Date - In Days( Day Of Week( :WR_Date ) )) - In Days( 5 ),
(:WR_Date - In Days( Day Of Week( :WR_Date ) )) + In Days( 2 )
) ) ) ) )

All I did is copied the first formula (for "week start") and replaced every reference to "week start" in the second formula with the copied information.

 

I added some extra spaces to (hopefully) see the formula  a little bit easier.

 

Also note that I did absolutely no testing to ensure this is correct.

Dan Obermiller
jthi
Super User

Re: combine formula

I think you could also directly remove Time Of Day(:WR_Date) because the result of that if statement should have same hours, minutes and seconds as the :WR_Date column

 

Formula(
	If(Day Of Week(:WR_Date) == 1,
		(:WR_Date - In Days(Day Of Week(:WR_Date))) - In Days(5),
		(:WR_Date - In Days(Day Of Week(:WR_Date))) + In Days(2)
	) - Time Of Day(:WR_Date)
),
-Jarmo
joann
Level IV

Re: combine formula

Thank you Jarmo! This works!
joann
Level IV

Re: combine formula

Thank you Dan! This works!