Results 1 to 9 of 9
  1. #1
    joycekuo is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    7

    Access 2010 Web Database Date() Function

    Hi Guys

    I am working onan Access 2010 web database and would like to know if there is aDate() function
    or similar, that I can use to default the start date on
    my form to bethe first day of last month, and
    the end date to be the last
    day of lastmonth

    Take today for example, the form default value for start date will be 1 May 2014 and end date 31


    May 2014.
    Thank you!

    Opps~ Apologies. This is suppose to be for the "Access" in general category. Will I be able to
    move this, or if someone could will be great.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Yes...it is exactly that: Date()

    i have home built functions to get these start / end dates
    1st of the month: StartOMonth() =(mm & "/1/" & yyyy)
    end o month = dateadd("d",-1,dateadd("m",1,StartOMonth())


  3. #3
    joycekuo is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    7
    Quote Originally Posted by ranman256 View Post
    Yes...it is exactly that: Date()

    i have home built functions to get these start / end dates
    1st of the month: StartOMonth() =(mm & "/1/" & yyyy)
    end o month = dateadd("d",-1,dateadd("m",1,StartOMonth())


    Thank you Ranman256 for your reply.

    I am still a bit lost, as I do not think the Web Access recognize the Dateadd function, and
    I cannot quite get the Start of Month function to work either. Should I be building this at
    a differnt place or calling it separately..??

    Click image for larger version. 

Name:	DefaultDate.jpg 
Views:	7 
Size:	161.2 KB 
ID:	16746

  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,772
    Start of the month for the current date:

    Month(Date()) & "/1/" & Year(Date())

    Try that in the DefaultValue property.
    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
    joycekuo is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    7
    Quote Originally Posted by June7 View Post
    Start of the month for the current date:

    Month(Date()) & "/1/" & Year(Date())

    Try that in the DefaultValue property.

    Thanks June7.
    That kinda work, so it has given me 06/01/2014 (given 6 is the current month?).

    I have tried to play with the time format to make it dd/mm/yyyy and also to pass
    the previous month instead, but ="1/" & Month(Date())-1 & Year(Date()) doesn't
    seems to be a web compatible format. =P


    Any ideas? And do you know how to add an end of month date?

  6. #6
    joycekuo is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    7
    YES!!! I've worked out the start date part in default value (no equal sign):
    "1/" & Month(Date())-1 & "/" & Year(Date())

    Just need the end of month date now, having it vary from 30th and 31st
    depending on previous month.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Beware of dates in non-Access standard format. Review: http://allenbrowne.com/ser-36.html

    If DateAdd() won't work, not sure how you can accomplish the end month calc.
    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.

  8. #8
    joycekuo is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    7
    Quote Originally Posted by June7 View Post
    Beware of dates in non-Access standard format. Review: http://allenbrowne.com/ser-36.html

    If DateAdd() won't work, not sure how you can accomplish the end month calc.

    Eeeeek~~ The database is in UK time format, so I am hoping the start date would work.
    Have tested a simple DateAdd function and it does work for Web DBs. Just not with the
    function above.

    I will have another crack at this...

  9. #9
    joycekuo is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    7
    FirstDay of Previous Month = DateSerial(Year(DateAdd("m", -1, Now)), Month(DateAdd("m", -1, Now)), 1)
    LastDay of Previous Month = DateAdd("d", -1, DateSerial(Year(Now), Month(Now), 1))

    Is works prefectly! Cheers All for your help.

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

Similar Threads

  1. Vlookup Function in MS Access 2010
    By pabbydf in forum Misc
    Replies: 4
    Last Post: 01-09-2014, 07:52 PM
  2. Need Help With DLookUp Function in Access 2010
    By fmartz in forum Programming
    Replies: 2
    Last Post: 09-05-2012, 09:34 AM
  3. Creating Browse function in Access 2010
    By martindenise in forum Access
    Replies: 3
    Last Post: 08-09-2012, 05:44 PM
  4. Replies: 1
    Last Post: 01-05-2012, 02:34 PM
  5. Access 2010 function
    By abm1961 in forum Access
    Replies: 5
    Last Post: 07-21-2011, 12:15 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