Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2007
    Posts
    20

    Unanswered: Displaying default field value depending on current date

    If the current date is in between 29 January and 6 July, I need the default value of a 'Semester' field to show as 1.

    If the current date is in between 21 July and 12 December, the value of 'Semester' should show as 2.

    The fields need to be overridden if crucial.

    I also don't know how difficult it is to define (within a table) the semester date ranges as applicable to each different year (2007, 2008, 2009) so that with the slight variations that occur each year, the function can remain up-to-date and accurate.

    Finally (and this is a stupid straightforward question about something I've done before but can't for the life of me remember how) how do I set the default value of a Year field as the current year (is it something like =Date(Year()) )? I keep getting error messages with everything I try, that's all.

    Thanks!

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Create a table with the following structure

    lowerDate datetime
    upperDate datetime
    defaultValue integer

    Then you can query your table like so to find out the default value that you want to use
    Code:
    SELECT defaultValue
    FROM   myTable
    WHERE  Now() BETWEEN lowerDate AND upperDate
    And finally, you were almost there
    Code:
    =Year(Date())
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •