+ Reply to Thread
Results 1 to 14 of 14

Date(ddd) in IF Function

  1. #1
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Date(ddd) in IF Function

    For example,

    A1= mon
    B1= 6.30am

    Mon to fri 6am to 9.30am &
    Mon to sun & public holiday 6pm to 12pm
    , the if function will return a value of 1 when input cell A1 & B1 fall within this range.

    The rest which is out of these 2 range, the function will return a value of 0,

    can I squeeze all these into 1 function with the bold text being my logical test?
    but first, im having problem with the date text in for IF function before solving the time...

    =IF(A1=TEXT(Monday,ddd),1,0) this doesn't work??
    Last edited by hhhhhhzzzz; 08-24-2015 at 03:42 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Date(ddd) in IF Function

    I dont really know what you are asking, but that formula needs to be...
    =IF(TEXT(A1,"ddd")="Mon",1,0)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Re: Date(ddd) in IF Function

    rephrased my question, ok thanks, will go try it out now.

  4. #4
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Date(ddd) in IF Function

    Hi,

    Try this which should account for everything except public holidays:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that I've assumed you meant 12midnight not 12pm for the second requirement. B1 needs to be formatted as time for this to work. Excel treats time as a number, so 0.5 is 12noon, 0.25 is 6am, etc - that's why the formula includes 6/24 etc - you can change these to 0.25 etc if you want - I just wanted it to be clear.

    To account for public holidays, you'd need to have A1 formatted as a date using custom format 'ddd' and compare the date with a list of public holidays in another range.

    Hope that's of some help.

    Regards,
    Aardigspook

    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark Thread as Solved'.
    You don't need to give me rep if I helped, but thanks are appreciated.

  5. #5
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Re: Date(ddd) in IF Function

    How can I amend this part?
    =IF(TEXT(A1,"ddd")="Mon",1,0)

    When I want to add from mon to fri?

  6. #6
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Re: Date(ddd) in IF Function

    woah, thanks for making an effort to come out with this long formula... really appreciate it! Shall try it out (:

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Date(ddd) in IF Function

    Perhaps this?
    =IF(LEFT(TEXT(A8,"ddd"),1)<>"s",1,0)

  8. #8
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Re: Date(ddd) in IF Function

    How to I amend the formula if I want it to have 12am to be included, in other words if B1 is 12am, the function will return a value of 1

    Please Login or Register  to view this content.
    I tried to add in = sign at the last logical test before B1<=1, but it doesn't work..

    the rest B1>=(6/24),B1<=(9.5/24) works when i want the number to be included.
    Last edited by hhhhhhzzzz; 08-23-2015 at 04:07 PM.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Date(ddd) in IF Function

    Quote Originally Posted by hhhhhhzzzz View Post
    =IF(OR(AND(OR(TEXT(A1,"ddd")="Mon",TEXT(A1,"ddd")="Tue",TEXT(A1,"ddd")="Wed",TEXT(A1,"ddd")="Thu",TEXT(A1,"ddd")="Fri"),B1>(6/24),B1<(9.5/24)),AND(B1>(18/24),B1<1)),1,0)
    If A1 contains a date you can reduce this:

    OR(TEXT(A1,"ddd")="Mon",TEXT(A1,"ddd")="Tue",TEXT(A1,"ddd")="Wed",TEXT(A1,"ddd")="Thu",TEXT(A1,"ddd")="Fri")

    To this:

    WEEKDAY(A1,2)<6
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  10. #10
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Re: Date(ddd) in IF Function

    Still having problem with the the value of 12am... T.T

    putting an equal sign for logical test B1<=1 does not return me the value of 1 if B1 is 12am...

    Anyone knows what's the problem?

  11. #11
    Registered User
    Join Date
    05-25-2012
    Location
    Chennai,TamilNadu,India
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    61

    Re: Date(ddd) in IF Function

    May be the below change in the same formula would do it.
    =IF(OR(AND(OR(TEXT(A1,"ddd")="Mon",TEXT(A1,"ddd")="Tue",TEXT(A1,"ddd")="Wed",TEXT(A1,"ddd")="Thu",TEXT(A1,"ddd")="Fri"),B1>(6/24),B1<(9.5/24)),AND(OR(B1=0,B1>(18/24)),OR(B1<1,B1=0))),1,0)

  12. #12
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Re: Date(ddd) in IF Function

    It works! Thank you!

  13. #13
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Date(ddd) in IF Function

    Glad to have helped. If you still need to include public holidays, let us know and I'm sure someone here will be able to work that out for you.

    Regards,
    Aardigspook

    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark Thread as Solved'.
    You don't need to give me rep if I helped, but thanks are appreciated.

  14. #14
    Registered User
    Join Date
    08-13-2015
    Location
    sg
    MS-Off Ver
    2010
    Posts
    17

    Re: Date(ddd) in IF Function

    Its okay! Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 06-12-2014, 11:37 AM
  2. [SOLVED] Function/formula to compare and insert todays date or yesterdays date
    By TC922 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-17-2013, 05:28 AM
  3. Replies: 0
    Last Post: 05-30-2013, 07:50 PM
  4. Function that will create a range based on a start date and end date
    By ckosman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-24-2013, 10:09 PM
  5. [SOLVED] Date function that compare 2 date in single column and return value
    By alimamak in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-20-2012, 06:45 AM
  6. Function to pull month-to-date, year-to-date for 2009
    By cacjr in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-14-2010, 07:57 PM
  7. Date Function formula that will return the date of a specific week
    By Greg in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2006, 12:10 PM

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.6.0 RC 1