+ Reply to Thread
Results 1 to 6 of 6

Thread: time function

  1. #1
    Registered User
    Join Date
    09-24-2011
    Location
    owensboro
    MS-Off Ver
    Excel 2003
    Posts
    2

    time function

    I am trying to make forms that employee less complicated as passable so they do not have to type in as much information. I am trying to make a formula that will take the hour of the day and return ether a 1 or a 2 that represents what shift it is according to the current time of day. Ex if hour = 19-6 then s =1 if hour = 7-18 then s = 2

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: time function

    THE NOW() Function is volatile so any formulas based on it will change automatically, is that what you want?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Valued Forum Contributor
    Join Date
    07-20-2011
    Location
    mysore
    MS-Off Ver
    Excel 2003
    Posts
    423

    Re: time function

    PL try this formula in the required cell

    =IF(OR(NOW()<=TIME(6,0,0),NOW()>=TIME(19,0,0)),1,IF(AND(NOW()<=TIME(18,0,0),NOW()>=TIME(7,0,0)),2,"" ))

  4. #4
    Registered User
    Join Date
    09-24-2011
    Location
    owensboro
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: time function

    Think you kvsrinivasamurthy but no matter what time I change the computer time to in bois and start menu time it will only bring up a 1. I trayed to modify yours with: IF(((NOW()<=TIME(6,0,0)),AND(NOW()>=TIME(19,0,0))),1,OR((NOW()<=TIME(18,0,0)),AND(NOW()>=TIME(7,0,0) )),2,) but it does not work either

  5. #5
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: time function

    NOW is both Day (integer) and Time (decimal) not just Time hence NOW() will always exceed 19:00 (unless date is set as day 0 in BIOS!)

    =1+AND(MOD(NOW(),1)>=TIME(7,0,0),MOD(NOW(),1)<=TIME(18,0,0))

  6. #6
    Valued Forum Contributor
    Join Date
    07-20-2011
    Location
    mysore
    MS-Off Ver
    Excel 2003
    Posts
    423

    Re: time function

    Pl replace the formula like this.Remember that only when change happens in workd\sheet this will change.

    =IF(OR(MOD(NOW(),1)<=TIME(6,0,0),MOD(NOW(),1)>=TIME(19,0,0)),1,IF(AND(MOD(NOW(),1)<=TIME(18,0,0),MOD (NOW(),1)>=TIME(7,0,0)),2,"" ))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0