Formatting dates problem

VegaLA

Registered User.
Local time
Today, 08:53
Joined
Jul 12, 2006
Messages
101
Hi all,
trying to format a date to YYYYMM so it can be used when it exports data to a excel sheet as part of the name, however i'm having problems getting formattting to use a date and format it the way I want, in this example YYYYMM. I tried it and its not working so I tried something not so unusual such as MM and using todays date it throws back 1/4/1900 in staead of just 05 which I was expecting.
The code I have is as follows:

dteYYYYMM = Format(Date, "mm")

dteYYYYMM is a date variable.

Can anyone see where I am going wrong ?

I am using Access 2003 SP2 on a XP Service Pack 2.

Thanks in advance,
Mitch....


OK, tried it using strings and it now seems to work.
 
Last edited:
Try this:

Format([Date],'yyyymm')

Or something like this would work...if not be awfully redundant:

dteYYYYMM = (DatePart('yyyy',[Date]) & Format(DatePart('m',[Date]),"00"))

This is assuming your field is named "Date".
 
You are trying to stuff a string into a date variable. Your variable needs to be a string.
 

Users who are viewing this thread

Back
Top Bottom