473,387 Members | 1,619 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,387 software developers and data experts.

Converting text to dates

How to I convert a text field into a date eg I want to load data with
entries like "01 Jan 03" into a date field.

Thanks
Jul 19 '05 #1
6 5700
ChrisP wrote:
How to I convert a text field into a date eg I want to load data with
entries like "01 Jan 03" into a date field.


http://www.mysql.com/doc/en/Date_and...functions.html

Jul 19 '05 #2
ChrisP wrote:
How to I convert a text field into a date eg I want to load data with
entries like "01 Jan 03" into a date field.


http://www.mysql.com/doc/en/Date_and...functions.html

Jul 19 '05 #3
Yes I've found those and str_to_date() looks ideal but I keep getting an
error message about an error in my sql syntax - I wonder what version
that function because available in because I am using 4.0.16 which is
the last version to have an odbc client available.

I've tried

select str_to_date ('1 Jan 2003','%e %b %Y');

as shown in the online manual and also

select str_to_date (my_field, '%e %b %Y') from table;

both with the same result
Aggro wrote:
http://www.mysql.com/doc/en/Date_and...functions.html


Jul 19 '05 #4
Yes I've found those and str_to_date() looks ideal but I keep getting an
error message about an error in my sql syntax - I wonder what version
that function because available in because I am using 4.0.16 which is
the last version to have an odbc client available.

I've tried

select str_to_date ('1 Jan 2003','%e %b %Y');

as shown in the online manual and also

select str_to_date (my_field, '%e %b %Y') from table;

both with the same result
Aggro wrote:
http://www.mysql.com/doc/en/Date_and...functions.html


Jul 19 '05 #5
ChrisP wrote:
Yes I've found those and str_to_date() looks ideal but I keep getting an
error message about an error in my sql syntax - I wonder what version
that function because available in because I am using 4.0.16 which is
the last version to have an odbc client available.
"STR_TO_DATE() is available as of MySQL 4.1.1."

So you have too old version of mysql server. Either you need to install= 4.1.1 version or need to use other solution for this problem.

Perhaps you need to get the date as string and convert it into date in
your program.

Jul 19 '05 #6
ChrisP wrote:
Yes I've found those and str_to_date() looks ideal but I keep getting an
error message about an error in my sql syntax - I wonder what version
that function because available in because I am using 4.0.16 which is
the last version to have an odbc client available.
"STR_TO_DATE() is available as of MySQL 4.1.1."

So you have too old version of mysql server. Either you need to install= 4.1.1 version or need to use other solution for this problem.

Perhaps you need to get the date as string and convert it into date in
your program.

Jul 19 '05 #7

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

Similar topics

22
by: Keith MacDonald | last post by:
Hello, Is there a portable (at least for VC.Net and g++) method to convert text between wchar_t and char, using the standard library? I may have missed something obvious, but the section on...
0
by: Massimo Fiorentino | last post by:
Hello there! I am a bit of a newbee into the mySQL world and I have a question regarding switching from one DB to another. I have for a couple of years used a very simple CMS-system created by...
3
by: Scott Kinney | last post by:
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...
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...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
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...
21
by: py_genetic | last post by:
Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the...
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...
1
by: =?Utf-8?B?bWFsdGFnaXJs?= | last post by:
I have a spreadsheet containing several dates (ex:1/4.2001). I am trying to convert the month (1) in text (January). I manged to do so using the Format Cells command after applying the Month...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.