473,407 Members | 2,598 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,407 software developers and data experts.

How to inser DateTime into the MySql Database

Hi friends,

I am finding some difficulties in the inserting date time into the database.

I am not able to convert the datetime into the mysql's Date Time format i.e.
'yyyy/mm/dd hh:mm:ss'

pls anybody can help me
Oct 3 '08 #1
3 1132
Plater
7,872 Expert 4TB
DateTime is not kept as a string, that's just how it is shown to you.
You should be able to use a Paramater and set the type to DateTime, then add the datetime object to it.

Example:
Expand|Select|Wrap|Line Numbers
  1. DateTime EDate = DateTime.Now;
  2. com.Parameters.Add("@EndDate", SqlDbType.DateTime);
  3. com.Parameters["@EndDate"].Value = EDate;
  4.  
Oct 3 '08 #2
DateTime is not kept as a string, that's just how it is shown to you.
You should be able to use a Paramater and set the type to DateTime, then add the datetime object to it.

Example:
Expand|Select|Wrap|Line Numbers
  1. DateTime EDate = DateTime.Now;
  2. com.Parameters.Add("@EndDate", SqlDbType.DateTime);
  3. com.Parameters["@EndDate"].Value = EDate;
  4.  


But i want to know how to write a command like insert because i am inserting so many things into the table and among those DateTime is one feild....
Oct 3 '08 #3
Plater
7,872 Expert 4TB
So write your command using the parameter?

http://bytes.com/forum/thread635615.html

http://bytes.com/forum/thread817960.html
Oct 3 '08 #4

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

Similar topics

6
by: Terry Hancock | last post by:
What do you do when a date or time is incompletely specified? ISTM, that as it is, there is no formal way to store this --- you have to guess, and there's no way to indicate that the guess is...
0
by: Jim S. | last post by:
I'm having a horrible time simply inserting the date in a MySQL database through a Visual Basic program. I have a table, called "ORDERS"; "ID" is the primary key. I'm trying the insert the date,...
3
by: heroe | last post by:
Hello *, i write you with an urgent problem. I would like to create forign keys to datetime field, but it doesn't seem to work. I get Can't create table '.\sampleDB\student_module.frm' (errno:...
2
by: bhv | last post by:
hello everybody, i have datetime format in mysql database table. now, in mysql date is YYYY-MM-DD format. how can i insert date in this format with VB Script ? i had tried following dim dt, dy,...
3
by: Aggelos | last post by:
I suppose that has been discussed. I search on google but couldn't find a short answer. I have a datetime field: 2006-10-10 12:00:00 And I want to get that in seconds. Should I break the date and...
2
by: nephish | last post by:
Hey there, i tried this question in the mysql group, but have not heard anything. i have a database with about 20 tables. The some of these tables have datetime type columns in them. What i am...
0
by: garfy | last post by:
Hi I am new memeber of this forum and I already got some answers so congrat on that jere is my question I have to add 2 new rows in a table in mysql and I do not know hot to do that I...
29
by: dyork | last post by:
When getting data from a database using the dbapi and an SQL query, how do you in general round trip the data? Especially date-time? An SQL datetime column translates nicely into a Python...
1
by: menmysql | last post by:
hi to all, i want to save my images into mysql database BLOB field. can any one help me regard this issue regards
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
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
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.