Solved

Format Date field in Access

Posted on 2013-05-21
5
899 Views
Last Modified: 2013-05-21
Hello,

I have a field in an Access Form that pulls from a date field in a SQL database.  The format is like this:

2013-12-25

The problem is that I want to format the field in Access to look like this:

12/25/2013

but still be able to edit it with in the Access form if I want.

Thanks,
Joel
0
Comment
Question by:Genius123
  • 3
5 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 39184739
you could use Format function

Format (MyDate, "mm/dd/yyyy")
0
 
LVL 11

Accepted Solution

by:
datAdrenaline earned 500 total points
ID: 39184966
Using a function to display the value the way you wish will render the value un-editable.  you will want to set the Format property of the TextBox control used to display the Date/Time typed value with this:

mm/dd/yyyy
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 39185002
If you are looking at the table contents in DataSheet view, then you will have to go into Design Mode of the Table object and change the Format property of the Date/Time field in question.  Do take note, however, that the format of how a Date/Time datatype field (column) is display has no effect on how the value is stored.  Date/Time values are always stored as a serial number that represents the number of days away from a 'base date'.  The base date (a serial number value of 0.0) is 1899-30-12 12:00AM in the scope of VBA and an Access Database Engine file.  In SQL Server, the base date is 1900-01-01 12:00AM, but when you create a Linked Table object in the Access UI environment, the ODBC driver knows how to handle this discrepancy in serial number base dates when viewing/using you data through the Linked Table object.  Also, note that with the serial number, the whole number of the floating point value represents the number of days away from the base date, the fractional part represents the time of day (the portion of the day away from midnight).
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 39185540
For the Date Text Box Control on your form, set the following properties:

1.) Input Mask .....  99/99/00;0;_
2.) Format ....  mm/dd/yy


ET
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 39185689
I personally really really dislike input masks! ... :) ... The Access UI does a pretty good job with out them.  With out an input mask, the user can enter a date in several valid date formats and the Access UI will "know" that it is a date and accept it, and display the value in the format indicated in the Format property (if it is set) or in the default format for that datatype.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now