cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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!

Recommended Articles