Results 1 to 5 of 5
  1. #1
    HeadGasket's Avatar
    HeadGasket is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Location
    Sonoma County, Northern California
    Posts
    33

    Year & Date issue. Show day of year as three numbers.

    I looked throught the Help on Access and I might not be able to do this but maybe one of you wizards out there knows a trick or two?

    I'm going to try using the year, day of year, hour & minute (24 hour clock) as a report number. It's set up in a field on a table. Right now I have....

    Default Value =Format(Now(),"yyyhhnn") 'which works but not exactly how I would like

    yy = Last two digits of the year
    y = Number of the day of the year (1 to 366) 'can this show three digits all the time?
    hh = Hour in two digits (00 to 23)
    nn = Minute in two digits (00 to 59)

    For instance, right now for Jan. 10th, 2012, 1306 hours the result would be 12101304 which, for all intents and purposes works, but I would prefer the "day of the year" to always be represented by three digits and not just when it hits day 100 of the year.



    I would prefer to see 120101304

    Thanks in advance,

    -David

  2. #2
    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,722
    Why? If you want unique numbers why not use an autonumber--just curious.
    You can always display/print Now() for the timestamp.

    This should do what you want though
    ReportNum = format(Now,"yy") & format(datepart("y",Now),"000")& format (Now,"hhnn")

  3. #3
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Since the value you are trying to come up with is essentially a calculated value derived from the date/time, you would not store it in the table but calculate and display it on the fly when you need it. You would store the date/time.

    I would do something like this

    =right(year(mydatefield),2) & format(datediff("d",dateserial(year(mydatefield)-1, 12,31), mydatefield),"000") & format(datepart("h",mydatefield),"00") & format(datepart("n",mydatefield),"00")

  4. #4
    HeadGasket's Avatar
    HeadGasket is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Location
    Sonoma County, Northern California
    Posts
    33
    Thanks, orange.

    Don't have a good explanation as to why I'm doing this and I admit it's a bit odd. I just can't seem to commit to a number to start out for Autonumber and starting at 00001 wouldn't go over with management (for this type of application). Goofy. I know.

    The bigger thing is that I'm a total noob and haven't figured out all the in's and out's of Access. Most of it is still a big mystery and the Help info within the program is pretty cool.....if you already know practically everything and need a quick reminder.

    Thanks for the help, though. I appreciate it.

    -David

  5. #5
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    By the way, if you are using this in a multi-user environment, you could conceivable have 2 people enter records within the same minute and you would end up with a non-unique value. You might consider including the seconds as a term in your expression.

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

Similar Threads

  1. Year over Year Comparision of Portfolio
    By richard70 in forum Queries
    Replies: 2
    Last Post: 10-31-2011, 08:19 PM
  2. Show Year with Quarter
    By Mordred in forum Access
    Replies: 9
    Last Post: 06-30-2011, 07:50 AM
  3. show records in this month last year?
    By geoffcox in forum Queries
    Replies: 4
    Last Post: 06-11-2011, 07:12 AM
  4. Replies: 2
    Last Post: 03-26-2011, 02:43 PM
  5. Year to date sum
    By jzacharias in forum Database Design
    Replies: 6
    Last Post: 09-10-2010, 10:38 AM

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