Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rashmip
Starting Member
4 Posts |
Posted - 2005-08-18 : 07:08:13
|
| I have problem is Set DateFormat "ymd" so database date column will have yyyy/mm/dd format.I am using java technology for inserting & retirval of records .java date functions retuns date in yyyy/mm/dd format.java.sql.Date.valueOf().so format should match & Search is based on date Column.needs urgent HelpThanks in advance. |
|
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2005-08-18 : 10:35:24
|
| I would let SQL keep it's default datetime type and handle the date format in the java code. It is not advised to mess with the datetime format in the database.AjHey, it compiles. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-18 : 10:43:17
|
| Use proper datetime variable in java and assign it the date and insert the recordDid you try that?What difficulty did you face?MadhivananFailing to plan is Planning to fail |
 |
|
|
rashmip
Starting Member
4 Posts |
Posted - 2005-08-20 : 04:22:06
|
| I am taking user input(from HTML Form)it is coming as String,then Inside servlet converting that String to Date object with dt1=req.getParameter("txt_dt");java.sql.Date mydt=java.sql.Date.valueOf(dt1);return type of this date object is yyyy/mm/dd and sql server smalldatetime is dd/mm/yyyy format so plz advice for same to bring both in same date Format. Then Comparsion can be done this Serach screen where user will give TO and From Date ,records will be retrived based on this query.Select Query select Enquiry_id,Student_name,Date_enquiry,Status from Enquiry_master where Course='"+Cour1+"'and Date_Enquiry between '"+dt4+"' and '"+dt5+"' order by Student_name "); |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-22 : 01:04:54
|
| No need for conversionLet the date to be stored in yyyy/mm/dd formatSee example hereDeclare @t smalldatetimeSet @t = '2005/08/22'Select @tSet @t = '2005-08-22'Select @tMadhivananFailing to plan is Planning to fail |
 |
|
|
rashmip
Starting Member
4 Posts |
Posted - 2005-08-22 : 04:48:00
|
| i need to store the string in date format to database plus ,later date is to be retived in String format.u can understand from last reply where i have pasted my java code also . |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-22 : 04:55:19
|
| In your example code, dont declare dt4 and dt5 to be stringDeclare them to be datetime and assign datetime value and do queryMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|