473,405 Members | 2,445 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.

Converting text dates to date format

I have a database that I imported from a csv file (I know, all the stories
start out this way...)

The dates were given as text strings of the form 'yyyymmdd', and were
imported as text.
Not all of the records have the date information, some are blank. One of
these is called 'bgman'

I'd like to convert those that have dates into a standard date field of the
form
mm/dd/yyyy.

After looking around on this newsgroup and some other Access sites,
here's what I did:

Created a new field, 'bgmandate' with type date, format Short Date.
I created an update query that 'attempts' to set the value of bgmandate with

CDate(Mid([bgman],5,2) & "/" & Mid([bgman],7,2) & "/" Left([bgman],4))

Here's what happens:

Nothing. All the values for bgmandate are blank.

What am I doing wrong?

Thanks in advance,

Scott Kinney
Nov 12 '05 #1
3 15274
"Scott Kinney" <sa******@ix.netcom.com> wrote in message
news:BO********************@comcast.com...
I have a database that I imported from a csv file (I know, all the stories
start out this way...)

The dates were given as text strings of the form 'yyyymmdd', and were
imported as text.
Not all of the records have the date information, some are blank. One of
these is called 'bgman'

I'd like to convert those that have dates into a standard date field of the
form
mm/dd/yyyy.

After looking around on this newsgroup and some other Access sites,
here's what I did:

Created a new field, 'bgmandate' with type date, format Short Date.
I created an update query that 'attempts' to set the value of bgmandate with

CDate(Mid([bgman],5,2) & "/" & Mid([bgman],7,2) & "/" Left([bgman],4))

Here's what happens:

Nothing. All the values for bgmandate are blank.

What am I doing wrong?


Might just be a typo in your post, but your expression is missing an "&" before the
final Left() function.
Nov 12 '05 #2

"Rick Brandt" <RB*****@Hunter.Com> wrote in message
news:bj************@ID-98015.news.uni-berlin.de...
my original post snipped for space
Might just be a typo in your post, but your expression is missing an "&" before the final Left() function.

It's a typo in the post. The expression in the update query has both (or
all) of its "&".

Scott
Nov 12 '05 #3
Scott,
What do you mean by "both (or all) of it's "&".
There should be 4 ampersands in the expression.

I just ran your query, (after adding the missing '&') and it worked fine for
me.

CDate(Mid([bgman],5,2) & "/" & Mid([bgman],7,2) & "/" & Left([bgman],4))

Converted a String 19990628 to
Date 06/28/1999
with a stored value of 36399.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Scott Kinney" <sa******@ix.netcom.com> wrote in message
news:e4********************@comcast.com...

"Rick Brandt" <RB*****@Hunter.Com> wrote in message
news:bj************@ID-98015.news.uni-berlin.de...
my original post snipped for space
> Might just be a typo in your post, but your expression is missing an

"&" before the
final Left() function.

It's a typo in the post. The expression in the update query has both (or
all) of its "&".

Scott

Nov 12 '05 #4

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

Similar topics

9
by: Thomas W | last post by:
I'm developing a web-application where the user sometimes has to enter dates in plain text, allthough a format may be provided to give clues. On the server side this piece of text has to be parsed...
7
by: Dana Shields | last post by:
I am attempting to upsize from access to SQL Server. I'm trying to convert my queries to SQL Server views; however, I'm having a lot of difficulty with the syntax differences. For instance, a...
2
by: Brian Candy | last post by:
I am guessing that this must be a common question, but I just can't find a simple solution for it by searching the newsgroups. I have a Text Box with a date in a UK format. The format has been...
1
by: John | last post by:
Hi I am using the below code to assign a date (entered in uk format) to a datetime variable. Dim myDateTimeUK As System.DateTime Dim ukCulture As CultureInfo = New CultureInfo("en-GB") ...
2
by: TofuTheGreat | last post by:
I'm using "Now.ToOADate" for a record timestamp in a small database app (it's what I want to do so don't try to disuade me ;-D). Anyway. I store the value of Now.ToOADate in a string field in...
2
by: Kakishev | last post by:
I have a problem at how best to convert a Date into a text field and keep the format dd/mmm/yyyy (01-FEB-2007). The problem is that dates are imported from SQL into an access front end Database....
8
by: Steve Cartnal | last post by:
I have tried every function that seemed applicable and can't seem to convert a simple text field containing numbers, for example "022807", into a date. Nor can I do the reverse and convert a date...
3
by: zshenk | last post by:
I need help converting dates. Currently, I have several tables and databases that use the format 1/20/2007. I have a table right now that uses the 20070120 format, and I was hoping that someone...
3
by: Jef Driesen | last post by:
How can I convert a date string to a number (e.g. a time_t value or a tm struct)? I know about the strptime function, but then I have to know the format string. And that is a problem. I'm trying...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.