how to insert date&time coloumn value in mssql

how to insert date&time coloumn value in mssql

View Answers

October 30, 2008 at 3:39 PM

hello,

in My sql there is a datatype "date" and "time". create a field which have date datatype in this u can store date and for time create a field which have time datatype in this u can store time.

If u want to store date and time in one field, for this u have to create a field which have varchar(25) datatype.

try this hope this will help u.

October 30, 2008 at 3:45 PM

Hi friend,

Code insert date and time in Database :

<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>
<%
int val=0;
Connection con=null;
PreparedStatement pstatement = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "file_upload";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url+dbName,userName,password);
java.util.Date now = new java.util.Date();
String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
String strDateNew = sdf.format(now) ;
String queryString = "INSERT INTO file_tbl set file_date='"+strDateNew+"'";
//out.println(queryString);
pstatement=con.prepareStatement(queryString);
val = pstatement.executeUpdate();
if(val>0)
{
%>
<br><br>
<b> <%=strDateNew%> inserted into Database.</b>
<%
}
}
catch(Exception e)
{}
%>

For more information on date and time visit to :

http://www.roseindia.net/jsp/fileupload.shtml

Thanks









Related Tutorials/Questions & Answers:
how to insert date&time coloumn value in mssql - JDBC
how to insert date&time coloumn value in mssql  how to insert date&time coloumn values in mssql  hello, in My sql there is a datatype...; Hi friend, Code insert date and time in Database : <% int val=0
how to insert value in dynamic table
how to insert value in dynamic table  i am creating a project...=con.prepareStatement("insert into "+company+year+"(firstname,lastname,email... student table. and company and year value i'm getting through company table.but apache
Advertisements
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  how to insert check box value to the database using jsp my code is <link href..." name="pmanager" value="Enter" ></td> <td align
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
how to delete specified coloumn from database(MS Access) by using windows application
how to delete specified coloumn from database(MS Access) by using windows application  how to delete specified coloumn from database(MS Access) by using c# windows application
PHP Insert Value
Insertion of data into table: We will study in this tutorial how to insert... default value earlier, Type: insert into student values ('name', 21, 'emp_id... server, following screenshots will help you to learn how to insert into values
how insert data from databse in array and compare new data to already stored value in array
how insert data from databse in array and compare new data to already stored value in array   hello all i tried to fetch data from databse and try to stored it in an array and i want to compare new value that come from database
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
JComboBox Insert Edited Value Into Table
JComboBox Insert Edited Value Into Table In this section we will read about how to make JComboBox an editable and then how to insert the new edited value... in to insert an editable value of JComboBox into a table. We will use an Java editor
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... created table in MSSQL,GUI in eclipse.How to achieve it.. Thanks & Regards
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... created table in MSSQL,GUI in eclipse.How to achieve it.. Thanks & Regards
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... created table in MSSQL,GUI in eclipse.How to achieve it.. Thanks & Regards
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
How to convert Mssql Procedure into Mysql Procedure.
How to convert Mssql Procedure into Mysql Procedure.  Hello Sir, I have a mssql procedure and i need it to be converted to mysql ... Below is my mssql procedure code.. WITH CTE AS ( SELECT ROW
How to convert Mssql Procedure into Mysql Procedure.
How to convert Mssql Procedure into Mysql Procedure.  Hello Sir, I have a mssql procedure and i need it to be converted to mysql ... Below is my mssql procedure code.. WITH CTE AS ( SELECT ROW
how to insert a summary values in grid
how to insert a summary values in grid  how to insert a summary value in grid
insert/update records with some of the columns having NULL value.
insert/update records with some of the columns having NULL value.  How do I insert/update records with some of the columns having NULL value
insert excel value in to oracle data base
insert excel value in to oracle data base  Hi All I am using this code for saving excel value to oracle database table. code is working properly but in table i am geting some diffrent type value like... o
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp...="2"><input type="submit" value="Send File"> </td></tr> <..."); File f = new File(saveFile); psmnt = connection.prepareStatement("insert
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp... colspan="2"><input type="submit" value="Send File"> </td></tr>..."); File f = new File(saveFile); psmnt = connection.prepareStatement("insert
how to insert image into server
how to insert image into server  how to insert an image into sql server and retrieve it using jSP
how to insert check box
how to insert check box   how to insert check box into jtable row in swing
how to get radio value
how to get radio value    how to retrive the option value and insert the next table pls give example
How to insert clob data??
How to insert clob data??  Can any one tell me in details how... pl/sql blocks and statements.I want to insert value of a textarea into clob... to insert more than 4000 characters.I have heard that clob fields can hold 4 gb
how to insert one table to anothere table
how to insert one table to anothere table  i have insert the record one table then i retrve the value of that table i insert one value at a time
How to insert rows in jTable?
How to insert rows in jTable?  Hi, I need to take input from user using JTable. I want an empty row to appear after clicking a insert button... not figure out how to. I used DefaultTableModel but wasnt able to insert a row
ModuleNotFoundError: No module named 'mssql'
ModuleNotFoundError: No module named 'mssql'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'mssql' How to remove the ModuleNotFoundError: No module named 'mssql'
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  ... reloading the page what i want is i can insert the multiple columns value generated... javascript code given at your site now sir problem is i am not able to insert
How to insert a car in the picture, insert a car in the picture, insert a car
How to insert a car in the picture       This is very interesting example because you will learn here how to insert an object on the another place. Picture: Take a picture of the road
How to insert data into MySQL Table?
How to insert data into MySQL Table?  Hi, How to insert the data...   Hi, The insert into query is used to insert the data into MySQL... ) Then we can use the following query to insert the data: insert into email(first_name
How to insert rows from Excel spreadsheet into database by browsing the excel file?
How to insert rows from Excel spreadsheet into database by browsing the excel file?  I want to insert rows from excel sheet to database.for this i... excel file and insert rows into MSSQL database in JSP???   Have a look
ModuleNotFoundError: No module named 'HTSQL-MSSQL'
'HTSQL-MSSQL' How to remove the ModuleNotFoundError: No module named 'HTSQL-MSSQL' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'HTSQL-MSSQL'  Hi, My Python
ModuleNotFoundError: No module named 'mssql-cli'
'mssql-cli' How to remove the ModuleNotFoundError: No module named 'mssql...ModuleNotFoundError: No module named 'mssql-cli'  Hi, My Python... have to install padas library. You can install mssql-cli python with following
ModuleNotFoundError: No module named 'mssql-runner'
'mssql-runner' How to remove the ModuleNotFoundError: No module named 'mssql-runner' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'mssql-runner'  Hi, My Python
ModuleNotFoundError: No module named 'mssql-scripter'
named 'mssql-scripter' How to remove the ModuleNotFoundError: No module named 'mssql-scripter' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'mssql-scripter'  Hi, My
ModuleNotFoundError: No module named 'pandas-mssql'
'pandas-mssql' How to remove the ModuleNotFoundError: No module named 'pandas-mssql' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'pandas-mssql'  Hi, My Python
ModuleNotFoundError: No module named 'pd-to-mssql'
'pd-to-mssql' How to remove the ModuleNotFoundError: No module named 'pd-to-mssql' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'pd-to-mssql'  Hi, My Python
ModuleNotFoundError: No module named 'peewee-mssql'
'peewee-mssql' How to remove the ModuleNotFoundError: No module named 'peewee-mssql' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'peewee-mssql'  Hi, My Python
ModuleNotFoundError: No module named 'PyStratum-MSSQL'
named 'PyStratum-MSSQL' How to remove the ModuleNotFoundError: No module named 'PyStratum-MSSQL' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'PyStratum-MSSQL'  Hi, My
ModuleNotFoundError: No module named 'storm_mssql'
'storm_mssql' How to remove the ModuleNotFoundError: No module named 'storm_mssql' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'storm_mssql'  Hi, My Python
ModuleNotFoundError: No module named 'bits-mssql'
'bits-mssql' How to remove the ModuleNotFoundError: No module named 'bits-mssql' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'bits-mssql'  Hi, My Python
ModuleNotFoundError: No module named 'c_mssql'
_mssql' How to remove the ModuleNotFoundError: No module named 'c_mssql...ModuleNotFoundError: No module named 'c_mssql'  Hi, My Python... to install padas library. You can install c_mssql python with following command
ModuleNotFoundError: No module named 'dbt-mssql'
'dbt-mssql' How to remove the ModuleNotFoundError: No module named 'dbt-mssql' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'dbt-mssql'  Hi, My Python
ModuleNotFoundError: No module named 'django-mssql'
'django-mssql' How to remove the ModuleNotFoundError: No module named 'django-mssql' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'django-mssql'  Hi, My Python
ModuleNotFoundError: No module named 'HTSQL-MSSQL'
'HTSQL-MSSQL' How to remove the ModuleNotFoundError: No module named 'HTSQL-MSSQL' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'HTSQL-MSSQL'  Hi, My Python
How to move a value in array?
How to move a value in array?   Enter value at the End: 5 Display... something wrong...pls help me fix this problem. when you insert value at the beginning... value at the End again 8 Display Array Elements Index at [0]0 Index at [1]0 Index

Ads