Date Conversion

G

Guest

I have a column in a table that I imported from a text file that contains a
date in the format YYYYMMDD. How can I convert this date to MM/DD/YYYY
format?
 
K

Ken Snell [MVP]

Add a new field to the table. Then run an update query to put the date into
that new field, using an expression to convert the text string to the date.
For example:

UPDATE Tablename
SET NewDateField =
DateSerial(Left([ImportedDate], 4), Mid([ImportedDate], 5, 2),
Right([ImportedDate], 2));
 
D

Douglas J. Steele

Another option is

UPDATE Tablename
SET NewDateField = CDate(Format([ImportedDate], "####\/##\/##")


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Ken Snell said:
Add a new field to the table. Then run an update query to put the date into
that new field, using an expression to convert the text string to the date.
For example:

UPDATE Tablename
SET NewDateField =
DateSerial(Left([ImportedDate], 4), Mid([ImportedDate], 5, 2),
Right([ImportedDate], 2));

--

Ken Snell
<MS ACCESS MVP>



DaveK said:
I have a column in a table that I imported from a text file that
contains
a
date in the format YYYYMMDD. How can I convert this date to MM/DD/YYYY
format?
 
G

Guest

Hi,
I have a similar situation.
I have a date 12/08/2004 which needs to be appended to another table as a
text file as 20041208 , YYYYMMDD format.
Thanks in advance.
Douglas J. Steele said:
Another option is

UPDATE Tablename
SET NewDateField = CDate(Format([ImportedDate], "####\/##\/##")


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Ken Snell said:
Add a new field to the table. Then run an update query to put the date into
that new field, using an expression to convert the text string to the date.
For example:

UPDATE Tablename
SET NewDateField =
DateSerial(Left([ImportedDate], 4), Mid([ImportedDate], 5, 2),
Right([ImportedDate], 2));

--

Ken Snell
<MS ACCESS MVP>



DaveK said:
I have a column in a table that I imported from a text file that
contains
a
date in the format YYYYMMDD. How can I convert this date to MM/DD/YYYY
format?
 
K

Ken Snell [MVP]

Use the Format function to convert the date to your desired format:

Format([DateFieldName], "yyyymmdd")


--

Ken Snell
<MS ACCESS MVP>

Kris said:
Hi,
I have a similar situation.
I have a date 12/08/2004 which needs to be appended to another table as a
text file as 20041208 , YYYYMMDD format.
Thanks in advance.
Douglas J. Steele said:
Another option is

UPDATE Tablename
SET NewDateField = CDate(Format([ImportedDate], "####\/##\/##")


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Ken Snell said:
Add a new field to the table. Then run an update query to put the date into
that new field, using an expression to convert the text string to the date.
For example:

UPDATE Tablename
SET NewDateField =
DateSerial(Left([ImportedDate], 4), Mid([ImportedDate], 5, 2),
Right([ImportedDate], 2));

--

Ken Snell
<MS ACCESS MVP>



I have a column in a table that I imported from a text file that contains
a
date in the format YYYYMMDD. How can I convert this date to MM/DD/YYYY
format?
 
G

Guest

I found the answer in a previous post.
I helps to read!
Thanks for the info!

Kris said:
Hi,
I have a similar situation.
I have a date 12/08/2004 which needs to be appended to another table as a
text file as 20041208 , YYYYMMDD format.
Thanks in advance.
Douglas J. Steele said:
Another option is

UPDATE Tablename
SET NewDateField = CDate(Format([ImportedDate], "####\/##\/##")


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Ken Snell said:
Add a new field to the table. Then run an update query to put the date into
that new field, using an expression to convert the text string to the date.
For example:

UPDATE Tablename
SET NewDateField =
DateSerial(Left([ImportedDate], 4), Mid([ImportedDate], 5, 2),
Right([ImportedDate], 2));

--

Ken Snell
<MS ACCESS MVP>



I have a column in a table that I imported from a text file that contains
a
date in the format YYYYMMDD. How can I convert this date to MM/DD/YYYY
format?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top