473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Problems with Date conversion from text format into date/time...

Problem!

I have a series of CSV files that I am bringing in to Access, contained
within each of them are 6 date fields, however, they are not being recognized
as dates…this is a big problem! the date looks like this:

20050816 23:59:59.000

I wrote a query to split up the numbers and then bring them back together in
the right order:

L1: Left([DATA_START_DATE],4)
M1: (Mid([DATA_START_DATE],5,2))
M1b: (Mid([DATA_START_DATE],7,2))
NEW_DATA_START_DATE: ([M1b] & "/" & [M1] & "/" & [L1])
DATA_START_DATE _2: IIf([NEW_DATA_START_DATE]="//","",[NEW_DATA_START_DATE])

Now it looks like this:

16/08/2005

This is fine, however; this is still text and not a date…. I firstly tried to
do a make table query, then go in to design view to change the field type
from text to date/time, this won’t work. I then made a blank table and
changed the field types in design view, and made my original query an append
query to put the data in to it. Which it did, but a message is appearing that
access has set 48067 fields to null and I can’t understand why?

If anyone can think or a better way of trying to do this I would be most
grateful, or even point out where I might be going wrong will do!

Thank you
--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
4 2030
There's a few ways to tackle this. below is one

Where the data is held in Table2 in a field called df

SELECT
df,
Left([df],4) AS df_year,
Mid([df],5,2) AS df_month,
Mid([df],7,2) AS df_day,
DateSerial([df_year],[df_month],[df_day]) AS df_date
FROM Table2

The df_date field is returning a date (not the string representaion of a
date that you are getting now).

--
Terry Kreft
MVP Microsoft Access
"Annie D via AccessMonster.com" <fo***@AccessMonster.com> wrote in message
news:54***********@AccessMonster.com...
Problem!

I have a series of CSV files that I am bringing in to Access, contained
within each of them are 6 date fields, however, they are not being recognized as dates.this is a big problem! the date looks like this:

20050816 23:59:59.000

I wrote a query to split up the numbers and then bring them back together in the right order:

L1: Left([DATA_START_DATE],4)
M1: (Mid([DATA_START_DATE],5,2))
M1b: (Mid([DATA_START_DATE],7,2))
NEW_DATA_START_DATE: ([M1b] & "/" & [M1] & "/" & [L1])
DATA_START_DATE _2: IIf([NEW_DATA_START_DATE]="//","",[NEW_DATA_START_DATE])
Now it looks like this:

16/08/2005

This is fine, however; this is still text and not a date.. I firstly tried to do a make table query, then go in to design view to change the field type
from text to date/time, this won't work. I then made a blank table and
changed the field types in design view, and made my original query an append query to put the data in to it. Which it did, but a message is appearing that access has set 48067 fields to null and I can't understand why?

If anyone can think or a better way of trying to do this I would be most
grateful, or even point out where I might be going wrong will do!

Thank you
--
Message posted via http://www.accessmonster.com

Nov 13 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's one way (all one line):

cdate(format(left([DATA_START_DATE],8),"####-##-##")) +
cdate(format(mid([DATA_START_DATE],10,8)))

This will not include the milliseconds.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQyibU4echKqOuFEgEQJ+oACgyK5HMN2qsEwnM7LQnSw+1X 3NQDcAoKCw
9drI52cA4twc9iGkX5pDmgaG
=WdLn
-----END PGP SIGNATURE-----

Annie D via AccessMonster.com wrote:
Problem!

I have a series of CSV files that I am bringing in to Access, contained
within each of them are 6 date fields, however, they are not being recognized
as dates…this is a big problem! the date looks like this:

20050816 23:59:59.000

I wrote a query to split up the numbers and then bring them back together in
the right order:

L1: Left([DATA_START_DATE],4)
M1: (Mid([DATA_START_DATE],5,2))
M1b: (Mid([DATA_START_DATE],7,2))
NEW_DATA_START_DATE: ([M1b] & "/" & [M1] & "/" & [L1])
DATA_START_DATE _2: IIf([NEW_DATA_START_DATE]="//","",[NEW_DATA_START_DATE])

Now it looks like this:

16/08/2005

This is fine, however; this is still text and not a date…. I firstly tried to
do a make table query, then go in to design view to change the field type
from text to date/time, this won’t work. I then made a blank table and
changed the field types in design view, and made my original query an append
query to put the data in to it. Which it did, but a message is appearing that
access has set 48067 fields to null and I can’t understand why?

If anyone can think or a better way of trying to do this I would be most
grateful, or even point out where I might be going wrong will do!

Thank you

Nov 13 '05 #3
Hi,

This would be fantastic if only i could get it work!....its creating the
fields but not putting any data in to them!

Thank you so much, i will persevere with it.

Annie
Terry Kreft wrote:
There's a few ways to tackle this. below is one

Where the data is held in Table2 in a field called df

SELECT
df,
Left([df],4) AS df_year,
Mid([df],5,2) AS df_month,
Mid([df],7,2) AS df_day,
DateSerial([df_year],[df_month],[df_day]) AS df_date
FROM Table2

The df_date field is returning a date (not the string representaion of a
date that you are getting now).
Problem!

[quoted text clipped - 18 lines]

This is fine, however; this is still text and not a date.. I firstly tried

to
do a make table query, then go in to design view to change the field type
from text to date/time, this won't work. I then made a blank table and

[quoted text clipped - 6 lines]

Thank you

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200509/1
Nov 13 '05 #4
Hi,

This would be fantastic if only i could get it work!

Thank you so much, i will persevere with it.
MGFoster wrote:
Here's one way (all one line):

cdate(format(left([DATA_START_DATE],8),"####-##-##")) +
cdate(format(mid([DATA_START_DATE],10,8)))

This will not include the milliseconds.
Problem!

[quoted text clipped - 28 lines]

Thank you

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200509/1
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: praba kar | last post by:
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type...
10
by: Fawke101 | last post by:
Hi there, I have a date field in SQL server - that holds dates as DD/MM/YYYY format (GB). Now, i have an ASP application that Adds/Edits records in this table; and i am having real problems...
1
by: Bruce Cushman | last post by:
My DB is Access 2000 based "possibly written in 2002" and I have to send and receive update files, ported to a UNIX server by FTP, DB unknown. The file content uses a fixed length string, zero...
0
by: Brian Conway | last post by:
I am having some validation and insertion problems. I am using a date picker that takes the selected date and puts it to ("dd-MMM-yyyy") format, as this was the only format that Oracle would...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
5
patjones
by: patjones | last post by:
Hi: I have a table that contains several date fields. I set the data type of those fields to Date/Time, and the format property (in table design view) to "mm/dd/yy". Likewise, in the form...
7
by: bruce.dodds | last post by:
Access seems to be handling a date string conversion inconsistently in an append query. The query converts a YYYYMM string into a date, using the following function: CDate(Right(,2) & "/1/" &...
4
by: atyndall | last post by:
OK, this is the relevant portion script: <?php $username = '__'; // MySQL Database Username. $password = '__'; // MySQL Database Password. $server = '__'; // MySQL Database server (most...
2
by: RN1 | last post by:
A TextBox displays the current date (in dd/mm/yyyy format) & time when a user comes to a page (e.g. 15/10/2008 1:36:39 PM). To convert the date into international format so that the remote server...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.