Results 1 to 6 of 6
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    set a date field to 1st january of this year


    Hi All

    I am stuck on this problem

    i have a form with to date fields startdate and enddate

    i would like to have the startdate field always set to 1st January of the current year but can't seam to get my head round the code

    any help would be awesome

    Steve

  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
    Have you looked at the DateSerial function?

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Rural Guy

    i think i have it now

    this formatting is working in a text box

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

    many thanks

    Steve

  4. #4
    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 don't think that will create a DateTime value where the DateSerial function with similar parameters will.

  5. #5
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi RuralGuy

    your right after playing around with it i used this

    =DateSerial(Year(Date()),1,1)

    this is what i was after

    many thanks for the input

    Steve

  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
    Excellent! Glad we could help. You learn quickly!

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

Similar Threads

  1. Replies: 4
    Last Post: 01-09-2013, 11:16 AM
  2. Replies: 4
    Last Post: 01-10-2012, 06:26 PM
  3. Replies: 10
    Last Post: 04-21-2010, 01:16 PM
  4. Use field value as the year in a date
    By Eveline in forum Queries
    Replies: 1
    Last Post: 03-11-2010, 10:58 AM
  5. Replies: 1
    Last Post: 06-11-2009, 05:40 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