Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fun with dates

Status
Not open for further replies.

xana

Programmer
Jul 6, 2001
3
US
i don't know a lot about access programming and i'm not sure the best way to go about this: i have a table that needs to display a letter that corresponds to a span of time. i need to take the current date and find out what quarter it's in. for example, march 13th would be in "H" where as march 2nd would be in "G". can i do that using a macro? should i use VB? i'm not sure how to go about doing that in an access form...any help would be appreciated! thanks!

-xana
 
Just a quick idea and only one way although I don't understand how, in your example, "H" and "G" correspond to quarters.

Steve King


Public CharValue() As String
Dim ElapsedDays As Integer

ElapsedDays = DateDiff("d", "1/1/" & Year(Date), Date) + 1
Select Case ElapsedDays
Case Between 0 And 30
CharValue = "A"
Case Between 31 And 60
CharValue = "B"
Case ...
Case Else
End Select
End Function Growth follows a healthy professional curiosity
 
Well, I'm confused as to why Mar 2 is in a different quarter than Mar 13. But you may be able to look up the function and ammend the firstweek of year argunment:

? datepart("q", #3/2/01#)
1
? datepart("q", #3/13/01#)
1
? Datepart("q", #4/1/01#)
2
MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
the "quarters" are completely made up. they happen to change on the first thursday in the first full week of a specified month.
 
i think my main question is how to get the current date...and then find out what day of the week it is...i can do the calculations, i'm just not sure how to make my program work with the table in access
 
Look for date functions in the help and you will see that you have the option of getting the current date by using:

Now()
Date()

You can get the day of the week by using Weekday(Date)
You can get the day of the month by using Day(Date)
You can get the day of the year by using DateDiff("d", "1/1/" & Year(Date), Date) + 1

If you look at the function and case statement above you could easily assign any value you wanted to any period of days.

Steve King




Growth follows a healthy professional curiosity
 
Well, Current date is either "Date" or "NOW", as in:

? Date
7/6/01
? Now
7/6/01 12:29:03 PM

Dayofthe week:

? WeekDay(Date)
6

where the day is an integer 1 to 7. Sun is one, Sat is 7, and today(Fri) is (obviously?) 6

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top