Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if time is in a range

Status
Not open for further replies.

FireGeek21

Technical User
Dec 12, 2007
218
US
I am new to Javascript and need to check to see if the current time is in the range of 00:00 - 07:00. If it is, we need the report to use yesterday's date. If the current time is < 23:59 then we can use today's date. Having issues with this because there is a 23:59 every day! Also not sure of the syntax.

Could anyone provide some assitance?

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
off the top of my head, something like this?

Code:
var n = new Date();
var y = n.getFullYear();
var m = n.getMonth();
var d = n.getDate();
	
var seven = new Date(y, m,d,0,7,0,0);
var jbm = new Date(y,m,d,23,59,0,0);
	
if (n > seven && n < jbm ){
	//do something
} else if (n < seven ){
	// do yesterday
} else {
	//do tomorrow
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top