Results 1 to 2 of 2

Thread: From Datetime field to 12 parts

  1. #1

    Lightbulb From Datetime field to 12 parts



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi friends,


    I have datetime field in column M


    I will take only Hour field from there.


    After that if an hour is between


    0-2 then "0AM-2AM"


    3-4 means "2AM-4AM"


    5-6 Means "4AM - 6 AM"




    .....Like that it follows


    the last one will be "10PM-12 AM".


    Kindly help me to get VBA Code.


    Regds,


    Hanu

  2. #2
    Super Moderator Bob Phillips's Avatar
    Join Date
    Mar 2011
    Posts
    1,819
    Articles
    0
    Excel Version
    O365
    Use a formula

    =CHOOSE(INT(HOUR(A2)/2)+1,"0AM-2AM","2AM-4AM","4AM-6AM","6AM-8AM","8AM-10AM","10AM-12PM","12PM-2PM","2PM-4PM","4PM-6PM","6PM-8PM","8PM-10PM","10PM-12AM")

Posting Permissions

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