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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format isn't formatting my date

Status
Not open for further replies.

malibu65k

Programmer
Sep 27, 2004
131
US
Hi All,

I have been using this Function for years but I can't get it to format my date.

In the table the format is "dd mmm yyyy" but it returns in a query in my code as "m/dd/yyyy" so

I use this code to format it back
--Format(rec("myDate"), "dd mmm yyyy")-- but it still comes back as "m/dd/yyyy"

I want to extract the day from it so I also tried
DatePart("d", rec("myDate")) and Day(rec("myDate")) functions and they both still return "m/dd/yyyy"

Any ideas on why none of these aren't working.

Thanks!!
 
You should be displaying all data in forms and reports. This allows you to set the format property of the control.

Are you using a recordset that you should be telling us about?

Duane
Hook'D on Access
MS Access MVP
 
Nevermind, sorry...

I found the problem. my variable for the date had to be set as a string.

Instead of...

Dim myDate as Date

it should have been...

Dim myDate as String
 


I found the problem. my variable for the date had to be set as a string.
REALLY?

Do you understand that STRINGS are not Real Dates, and are entirely useless as data elements, especially in m/dd/yyyy structure, which will collate

12/01/2010

before

2/01/2010

You need to be very careful! Perhaps explain what you're trying to do.



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks, I am aware. I didn't need the date itself I needed in that particular date format to get the day in a 2 number format like a "03" instead of "3" and the day would only give me "3/". Everything else I tried didn't work.
 
I would not convert a date to a string to get a day number out. If you want the day of the month of a field, try:
Code:
   Format(Day([DateValueOrExpression]),"00")

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top