Results 1 to 6 of 6
  1. #1
    bewsh1987 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Location
    UK
    Posts
    20

    Get Number From Day Name

    Hi All

    Is there an expression that will return the day name to day number Monday = 1, Tuesday = 2..... Sunday = 7

    I can easily do it from day number to day name however I would like to do the reverse

    I can create my own function to do this no problem(Trying to stay away from VBA)

    I would like to do this as an expression only



    Thanks in advance

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    They already have constant values....

    vbMonday
    vbTuesday
    etc

    if format("w",date()) = vbMonday then

  3. #3
    bewsh1987 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Location
    UK
    Posts
    20
    Quote Originally Posted by ranman256 View Post
    They already have constant values....

    vbMonday
    vbTuesday
    etc

    if format("w",date()) = vbMonday then
    Thanks for replying however this is not what I am looking for

    I have a table with day names Monday Tuesday etc, in the query I would like the [Day_name] to show a number using expression (no vba)

    Monday = 1, Tuesday = 2..... Sunday = 7

    again with no vba

    Thank you

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Switch([Day_name]="Monday",1, [Day_name]="Tuesday",2, [Day_name]="Wednesday",3, ...you finish)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    bewsh1987 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Location
    UK
    Posts
    20
    Quote Originally Posted by June7 View Post
    Switch([Day_name]="Monday",1, [Day_name]="Tuesday",2, [Day_name]="Wednesday",3, ...you finish)
    Works a treat

    June7 Thank you thank you and thank you

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Put it in a table.
    monday, 1

    etc

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

Similar Threads

  1. Replies: 5
    Last Post: 11-30-2014, 12:46 PM
  2. convert number to text number like in cheque
    By ravideep in forum Reports
    Replies: 1
    Last Post: 03-12-2013, 05:55 AM
  3. Replies: 6
    Last Post: 01-24-2013, 10:02 PM
  4. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  5. Replies: 6
    Last Post: 07-25-2011, 01:54 PM

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