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

Truncated incorrect time value: '1:05 AM'

40
Hai All,

This is my create statement
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `dbname`.`tablename` (
  2. `vh_id` int(10) unsigned NOT NULL,
  3. `gh_utc` time NOT NULL,
  4. `gh_mydate` date default NULL,
  5. `gh_serverdate_time` timestamp NOT NULL default CURRENT_TIMESTAMP,
  6. KEY `FK_geo_gpsdata_2` (`vh_id`)
  7. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
when i query this table im getting "Truncated incorrect time value: '1:05 AM"
the below is the query.Not getting why the time value is truncated.
Expand|Select|Wrap|Line Numbers
  1. SELECT time_format(gh_utc ,'%H:%m:%s'),
  2. date_format(gh_mydate,'%d/%m/%Y')
  3. FROM tablename where vh_id='1' and timestamp(gh_mydate,gh_utc)
  4. between timestamp('2009/01/01','1:05 AM') and timestamp('2009/01/16','1:05 PM') ;
Awaiting for the reply.

Thanks in advance
Jan 12 '09 #1
4 14912
Atli
5,058 Expert 4TB
Hi.

The string "1:05 PM" is an invalid time value. MySQL uses a 24 hour "HH:MM:SS" syntax.

As a result, MySQL *truncates* the value you gave it and turns it into the most likely alternative that fits the required syntax, which becomes "01:05:00".

To get the effect you are after, you need to use "13:05" for the PM value and "01:05" for the AM value.
Jan 12 '09 #2
crs27
40
thanks for the reply Atli.
I realized that,but i did not want to add 12 in my logic and then to make it 24 hr time.
Is their any other way that i get 24hr time in the query itself.
Jan 12 '09 #3
Atli
5,058 Expert 4TB
You could use the STR_TO_DATE function to convert it into a valid value.

Although, I would advise you to have your front-end do this conversion instead. It's a lot cleaner that way.
Jan 12 '09 #4
crs27
40
thanks again atli.Shal follow the same.
Jan 12 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: theintrepidfox | last post by:
Dear Group Some but not all of the dates are incorrect converted (incremented by 1 day) with the following SQL statement. SELECT DISTINCT CONVERT(datetime,cast(ReturnedByDate AS int)) AS...
8
by: skinnybloke | last post by:
Hi - I have a problem with a memo field being truncated to about 255 characters when running a Access 2002 query. This only seems to happen if I use SELECT DISTINCT. It works ok using SELECT by...
5
by: m_t_hill | last post by:
Running MS Access 2000 MS Windows XP Pro This has caused me a lot of hair loss in the last few days so would appreciate any help. I am running code to append/update a local access database...
0
by: Ed Bick | last post by:
Well, I read today about how I could set the dropdown value to False to change the control from presenting a Calendar to cycling through the times. Before getting that, I developed a custom Time...
4
by: Jack | last post by:
THE FOLLOWING IS A PART OF CODE FROM A ASP PAGE <% sql01 = "SELECT COUNT(*) AS reccount FROM Equipmenttbl " sql01 = sql01 & "WHERE Equipmenttbl.GrantID = " & GrantID 'Response.Write sql01 &...
12
by: Jack | last post by:
Since, I have not got some desired advise, I am reposting this for some asnwer/valuable suggestion. Thanks. THE FOLLOWING IS A PART OF CODE FROM A ASP PAGE <% sql01 = "SELECT COUNT(*) AS...
8
by: Derek | last post by:
Hi Hope that this is the correct newsgroup for this, sorry if it is not. I have the following code which is used to display the data brought back from a MySQL database in an input box so that...
13
by: chromis | last post by:
Hi, I have a query which updates the projects table of my database, however when I try to run my query with blank values i get the following error: Data truncation: Data truncated for column...
1
by: sanjupommen | last post by:
I am in the process of exploring the possibility of providing our products on databases other than Oracle.I am able to migrate the data, procedures etc without too much effort (latest version of DB2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.