Results 1 to 6 of 6
  1. #1
    Andycam is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    6

    Unhappy Convert text (YYMM) to numeric retaining the lead zero or zero's (ie Year 2000)

    I have a DB containing over 4 million rows of data, each with a SALES_PERIOD based on YYMM. Our Developers set it up as Text, and index this item accordingly, I would like to format as numeric with the lead zero to allow quicker indexing, but when I format it it returns to text this is the formula I use?



    Format((Val([SALES_PERIOD])), "0000")

    Can somebody please help me.

    Andycam

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    How would leading zero help with indexing?

    Numbers can't have leading zeros, only text strings will retain leading zero.

    Why do you need leading zero? Don't all the values already have 4 digits?
    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.

  3. #3
    Andycam is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    6
    Hi June7

    Sorry may have misled you, I want quicker indexing, but the developers tell me that text is much slower than numeric, and you can't use the same filters as numeric. That is why I want the text value as numeric with a leading zero.

    >Why do you need leading zero? Don't all the values already have 4 digits?

    When the text is changed to numeric it changes from 0908 to 908 that is why I wanted the zero.

    Andycam

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Can you tell us more about your application and why "faster indexing" is required?

    In my view, you would only use a numeric value if you were using it with some arithmetic calculation, but there may be other circumstances that would warrant numerics.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Well, you can't have the values as numeric and retain the leading zeros. Just can't, period. Numbers don't have leading zeros. If there is a leading zero then it isn't a number, it's a text string.

    The data should have been saved as a full date value. Dates are really saved by Access as a number.

    Try indexing on the value converted to a date, assuming all dates are years 2000 and later:

    DateSerial("20" & Left("0908",2), Mid("0908",3,2), "01")
    Last edited by June7; 08-29-2012 at 05:15 PM.
    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.

  6. #6
    Andycam is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    6

    Wink

    Thanks, guys, it looks like I can't get the numerics so I will stick to my text. Thanks again for the help, I will use it as is.

    That answers my question.

    Andycam

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

Similar Threads

  1. Convert time stamp Now() to Fiscal Year
    By ajcke in forum Queries
    Replies: 17
    Last Post: 05-17-2012, 12:51 PM
  2. Replies: 2
    Last Post: 09-25-2011, 08:52 AM
  3. Numeric vs. Text
    By Niki in forum Access
    Replies: 4
    Last Post: 06-10-2011, 01:28 AM
  4. Linked file text/numeric filter performance
    By awc109 in forum Import/Export Data
    Replies: 0
    Last Post: 04-19-2011, 11:02 AM
  5. Justify numeric text field
    By tpcervelo in forum Queries
    Replies: 2
    Last Post: 01-27-2011, 03:50 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