Hello. I need to convert dates in this format to recognizable dates:
20121102 (formatted in text).
In Excel, the conversion formula is =DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
I can not figure out how to convert them in Access.
Thanks!
4 3844
There is probably alot smarter ways to do this but you could try: -
Public Function ConvertDate(strDate As String) As Date
-
Dim intYear As Integer
-
Dim intMonth As Integer
-
Dim intDay As Integer
-
intYear = Left(strDate, 4)
-
intMonth = Mid(strDate, 5, 2)
-
intDay = Right(strDate, 2)
-
Dim s As String
-
s = "" & intMonth & "/" & intDay & "/" & intYear
-
ConvertDate = CDate(s)
-
-
End Function
This video will show you how to implement custom functions in access.
If you want to do the conversion in an Access query you can use a computed field based on the DateSerial function in Access that is very similar to the Date function in Excel which you quote.
The SQL would be something like this: - SELECT
-
[YourDate],
-
DateSerial (Left([YourDate], 4), Mid([YourDate], 5, 2), Right([YourDate], 2)) AS YourRealDate
-
FROM
-
[YourTable];
The names of the actual fields and the table or query concerned would have to be used in place of the examples above, but it might get you started without having to define a custom function first.
If you use the Access query editor you can enter the following in the Field Name part of the grid to create the computed field: - YourRealDate: DateSerial (Left([YourDate], 4), Mid([YourDate], 5, 2), Right([YourDate], 2))
-Stewart
I had forgotten about the DateSerial function. Thanks for the reminder.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Christophe Cerbourg |
last post by:
hi,
Bonjour,
I'm using PHPMailer class to send mails and it works fine for HTML ones.
But I can't manage to send correctly a text formatted mail...
I tried this :
- $message = "first...
|
by: Ciar?n |
last post by:
I have a table with over a million rows and one of the fields contains
amounts of money in text format.
What is the most efficient way of converting this field to a number
format that I can sum...
|
by: Eddy Soeparmin |
last post by:
Hi,
I need to display a DateTime field in 'mm/dd/yyyy' in a DataGrid.. On
myGrid1 - Properties - Columns - myColumn1 - Text format string:
I tried to put 'mm/dd/yyyy' in there and it displays...
|
by: charliewest |
last post by:
Hello -
I am pulling a datetime var from a dataset which is binded to a repeater
control as follows:
<%# DataBinder.Eval(Container.DataItem, "DateCreated") %>
The datetime value returns...
|
by: jakub.bauer |
last post by:
Hi,
I have a table with in MS SQL database. A table consist a list of items
bought by a customer with, item prices, item nubers etc. I would like to send
an email with a list of items in the...
|
by: savigliano |
last post by:
hello, i am doing a date comparation and i have reallize that the data
i have in my database (general date format) it is causing me problems,
and because i donīt need the time data i would like to...
|
by: Mallik02 |
last post by:
Hi
I am new to MS-Access, I am getting the date in text format when I export it from other application. Could you please explain if there is any "Query" in Access to convert the text dates into...
|
by: Charlote |
last post by:
Hello,
I am a beginner in python, and have a question..
I need to create a list of all dates between two dates..
Lets say beggining date= 2008-1-15
enddate= 2008-2-20
how do I...
|
by: Jeff |
last post by:
Hey
I'm wondering how the Fixed-Width Text Format is
What I know is that the top line in this text format will contain column
names. and each row beneath the top line represent for example a...
|
by: Bill Eberle |
last post by:
In Access 2007 ADP connected to SQL Server Express, most forms allow Text Format attribute of Rich Text, but a few do not.
In each case the SQL Server table field connected to the Access Text Box is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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...
|
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...
| |