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

CAST / Date_FORMAT function

Hi,

I'm new to MySQL and I have qustion regarding to CAST and Date_Format
functions. I'm trying to convert a column 'Time' varchar(50) to
datetime datatype by "select date_format(cast(time as datetime),
'%m/%Y') from yo where id = 1" but the data returns incorrectly. For
example, the id 1 the time is '28-4-2004-4:11' once I ranthe query,
the return data is 04/2028. Looks like MySQL treated 28 as the year.
What can I do to make it returns correct info as 04/2004?

Thanks for your help!
JL
Jul 20 '05 #1
0 1922

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

Similar topics

2
by: Rick | last post by:
I have been trying to run this MySQL query using PHP: SELECT id, trans_type, remote_addr, DATE_FORMAT(time, '%M %e, %Y %r') as time FROM transactions WHERE client_id = " . $client_id . " ORDER...
2
by: Johan den Boer | last post by:
Hi, What is wrong with this code ? SELECT DATE_FORMAT( myfield, GET_FORMAT( TIMESTAMP, 'EUR' ) ) FROM T_TABLE; regards Johan
0
by: Aaron W. West | last post by:
Fun with CAST! (Optimized SQLServerCentral script posts) I found some interesting "tricks" to convert binary to hexadecimal and back, which allow doing 4 or 8 at a time. Test code first: --...
5
by: MC | last post by:
Hi If I have a pointer to a some structure say for example payroll_ptr where struct payroll { ... } has some members and if i use a function argument as int function_process ( (payroll_ptr)...
16
by: Martin Jørgensen | last post by:
Hi, Short question: Any particular reason for why I'm getting a warning here: (cast from function call of type int to non-matching type double) xdouble = (double)rand()/(double)RAND_MAX;
3
by: sang | last post by:
Hai I want to change the date format at the time of inserting the record. i done it but one error in the insertion. The query is insert into mytable(update) values(date_format(...
1
by: sang | last post by:
Hi In my table the date format is changed to 06-feb-2007.The query i execute is select date_format(col.name,"%e-%b-%Y") from tablename; This is worked well in local but in the web it will...
3
by: adamalton | last post by:
I am trying to take a date in the format "YYYY-MM-DD" and get from it the month as a word (e.g. July) and the day as a 2 digit number (e.g. 24). I am trying to use the date_format function, (new...
16
by: laverdir | last post by:
<? $query = "SELECT " . $this->tabela3 . ".id, " . $this->tabela3 . ".naziv, " . $this->tabela3 . ".spisatelj, " . $this->tabela3 . ".najava, " . " DATE_FORMAT(" . $this->tabela3 ....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.