Results 1 to 2 of 2
  1. #1
    jamiers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    9

    Stripping Minutes From Hour When Only 00., Access 2010


    My supervisor wants me to create the following expression in a query. I need to merge fields and format to get it done.

    Field 1: Date and Start Hour Training
    Field 2: End Hour Training

    New merged field...output should be something like this
    Sa 9a-4p
    M 9:30a-4:15p
    Th 10:00a-1p

    I have created a lookup for the day -- so I am not concerned about that... Look up Saturday, return Sa... look up Monday, return M.

    But... what I can't figure out is how to dump the minutes if ONLY equal to 00 (9:00 should come back 9a, and 4:15 should come back as 4:15p).

    This what I have going:
    TrainingDayTime: [ShortDay] & " " & [TrainingRange]

    Short Day is the lookup for the DayCode (Sa, Su, M, Th)
    Training Rage field shows this expression: TrainingRange: Format([Start Date/Time],"h:nna/p") & "-" & Format([End Date/Time],"h:nna/p")

    What can I do to those nn's to get them to only show if it is minute 01 to 59 and not 00?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    To clarify,

    what you want is

    Sa 9a-4p

    what you are getting is

    Sa 9:00a-4:00p

    try

    TrainingRange: Format([Start Date/Time],iif(datepart("n",[Start Date/Time])=0,"ha/p","h:na/p")) & "-" & Format([End Date/Time],iif(datepart("n",[End Date/Time])=0,"ha/p","h:na/p"))

    If you were happy with Sat rather than Sa, you could add 'ddd' to the start of your format string e.g. "ddd ha/p" which would save you your shortday function


Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-30-2015, 05:17 AM
  2. Replies: 1
    Last Post: 10-20-2013, 10:04 AM
  3. Replies: 1
    Last Post: 02-28-2012, 09:16 PM
  4. Help! Access Keeps Stripping Leading Zero
    By geraldselectric in forum Access
    Replies: 2
    Last Post: 01-15-2012, 12:04 PM
  5. stripping away access
    By emilylu3 in forum Access
    Replies: 1
    Last Post: 01-04-2006, 08:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums