472,958 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 15260
"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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.