Getting a date from a Number????

paulmcdonnell

Ready to Help
Local time
Today, 22:38
Joined
Apr 11, 2001
Messages
167
Quickie Guys


I know how to use datepart to get the value of a month from a date e.g. Datepart("m",01/08/2002). (UK) gives 8

Does anyone know how you go the other way around.
eg given 8 and want to express the first day of that month 01/08/2002 or give 3 as a quarter and express the first day of the quarter - 01/06/2002.

Hope some date guru can offer some help.

Thanks in advance

Paul
 
Last edited:
Another possibility if DATESERIAL proves to be too tricky or not quite right is this...

If given a month, it is EASY....

loMonthNumber = DATEPART("m",Now)
stDateString = "01/" & CStr(loMonthNumber) & "/" & DATEPART("yyyy", Now)

dtDateFirst = CDat(stDateString)

For the quarter, the expression becomes

loQuarterNumber = DATEPART("q",now)
loMonthNumber = 1 + ( 3 * ( loQuarterNumber - 1 ) )
stDateString = "01/" & CStr(loMonthNumber) etc.

This is the long way around but it might be clearer and easier to understand, which is always an issue in implementation.
 

Users who are viewing this thread

Back
Top Bottom