Results 1 to 8 of 8
  1. #1
    mtrainier70 is offline Novice
    Windows Vista Access 2003
    Join Date
    Jun 2014
    Posts
    1

    Deriving & reformating a date field from another date field in the same table

    A novice question. I've inherited a database into which the user (not me) is entering essentially the same Date data twice: field 1 contains 6/19/2014 and for field 2 they enter June-14 (the month and year from field 1).



    I suspect there should be a way to derive and then reformat the display of field 2 based on the contents of field 1, such that the user only has to enter the first. Is this true? If so, how?

    (I know there really is no need for the 2nd field, but existing reports and queries are built around it -- so for right now, I'm just trying to eliminate the duplicate data entry)

    Thank you

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Look into the Format() function.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    http://www.techonthenet.com/excel/fo.../monthname.php

    This link might be helpful too.

    So in the 'on exit' of your date field you could have something like

    UselessField = Monthname(datepart("m",[DateField]), false) & "-" & datepart("d", [Datefield])

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Minor change. It should be the last 2 digit of year and not day. Also check for null.

    UselessField = IIF(ISNULL([DateField]), NULL, Monthname(datepart("m",[DateField]), false) & "-" & RIGHT(Year([Datefield]), 2))

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    oop you're right I didn't even look I thought it was the month/day not the month/year

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I think using Format() would have been:
    UselessField = IIF(ISNULL([DateField]), NULL, Format([DateField],"mmm-yy")

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    yep, the only reason I suggested the monthname function was he actually typed out the full month name and that was the only way I knew of to get a non-truncated month name.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Oops, I should have user "mmmm-yy"

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

Similar Threads

  1. Replies: 2
    Last Post: 05-22-2014, 06:11 PM
  2. Replies: 3
    Last Post: 12-24-2013, 04:20 PM
  3. Replies: 15
    Last Post: 04-06-2012, 10:57 AM
  4. Replies: 2
    Last Post: 03-31-2012, 07:53 AM
  5. Replies: 1
    Last Post: 02-06-2011, 06:36 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