Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Text to Date type

Posted on 2002-07-15
8
Medium Priority
?
225 Views
Last Modified: 2006-11-17
I have a text field “EndDate” in my table, half of data have format: mm/dd/yy the rest dd-MMM
I want to convert all data from text to date type format: mm/dd/yy.
Data in this field are like :
01-Jan
02-Jul
20-Dec
24-Dec
12/26/01
12/27/01
I want to put year 2001(01) at the end where it missing and then convert all data to date type.
May data in “EndDate “should look like :
01/01/01
07/02/01
12/20/01
12/24/01
12/26/01
12/27/01

Thanks

Taras

0
Comment
Question by:Taras
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 7155110
Then I would use Cdate(field)

In an update query use:

IIF(len(stringdate)<7,Cdate(stringdate&"-2000"),Cdate(stringdate))

Nic;o)
0
 
LVL 28

Accepted Solution

by:
TextReport earned 800 total points
ID: 7155125
You need to know about a couple of functions to do this and I would create a new field (always advisable as is a backupo before you start) Then you can update the new field with an update update query.

UPDATE mytable
SET mynewdate = iif(isdate(myolddatefield), cdate(myolddatefield),cdate(myolddatefield & "-2001")

Cheers, Andrew
0
 

Author Comment

by:Taras
ID: 7156081
Hi Andrew.
This is working fine.
Thanks for your help,
Taras.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:Taras
ID: 7156943
I have just one small problem Andrew it shows me year 2002 and I want 2001.
Any idea what I did wrong?
Taras.
0
 
LVL 28

Expert Comment

by:TextReport
ID: 7157434
Change the update query so it does a select with the update to part as another field and past some of the datefield and calculated field as an example of where they are going wrong, also, what version of Access is it?

Cheers, Andrew
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7157468
Looks like my comment has been invisible....

Nic;o)
0
 

Author Comment

by:Taras
ID: 7163267
Hi Nico5038.
I tried you answer and it shows 2001properly and that is what I need.
I will post this question again to allocate points to you.

Thanks Taras.

0
 
LVL 54

Expert Comment

by:nico5038
ID: 7163349
Thanks for the gesture ;-)

Both solution will work, but both have the same "problem" that an invalid date won't be processed correctly.
You need to be sure that no Nulls or other garbage is in this field.
From that point of view you should first run a select query like:
SELECT iif(isdate(myolddatefield), "Yes",IIF(IsDate(myolddatefield & "-2001"),"Yes","No")) AS DateOK From tblWithDate WHERE DateOK = "No";

This will show the problem fields.

Nic;o)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

636 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