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 |
|
bhanu2217
Starting Member
35 Posts |
Posted - 2009-12-01 : 08:43:40
|
| I have a field in database which is of type datetime.I want to use a select query to get this field in DMY format without time.Please let me know the syntax,www.JamboreeBliss.com |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-01 : 08:59:36
|
quote: Originally posted by bhanu2217 I have a field in database which is of type datetime.I want to use a select query to get this field in DMY format without time.Please let me know the syntax,www.JamboreeBliss.com
Where do you want to show data?If you use front end application, do formation thereOtherwiseselect convert(char(10),date_col,103) from your_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
bhanu2217
Starting Member
35 Posts |
Posted - 2009-12-01 : 09:09:29
|
quote: Originally posted by madhivanan
quote: Originally posted by bhanu2217 I have a field in database which is of type datetime.I want to use a select query to get this field in DMY format without time.Please let me know the syntax,www.JamboreeBliss.com
Where do you want to show data?If you use front end application, do formation thereOtherwiseselect convert(char(10),date_col,103) from your_tableMadhivananFailing to plan is Planning to fail
So basically you are converting the datetime into character?actually i am using this in my stored procedure, in the final step while returning but if i use the above in my query the column name of the date field value goes blank.I am assigning the result of the stored procedure to a DataSet and than a GridViewhere is my Query ReqDate is the field that i want to return in DMY format without time.set dateformat dmy select distinct DelDet.kitID,Reg.userid, convert(char(10),DelDet.ReqDate,103),Reg.name,Reg.street1,Reg.street2,Reg.pin,Reg.category,Reg.kit_type,Reg.alternate_phone from @table1 DelDet JOIN db_registration Reg on Reg.userid=DelDet.userid www.JamboreeBliss.com |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-01 : 09:13:13
|
| select distinct DelDet.kitID,Reg.userid, convert(char(10),DelDet.ReqDate,103) as ReqDate,Reg.name,Reg.street1,Reg.street2,Reg.pin,Reg.category,Reg.kit_type,Reg.alternate_phone from @table1 DelDet JOIN db_registration Reg on Reg.userid=DelDet.userid MadhivananFailing to plan is Planning to fail |
 |
|
|
bhanu2217
Starting Member
35 Posts |
Posted - 2009-12-01 : 09:34:13
|
quote: Originally posted by madhivanan select distinct DelDet.kitID,Reg.userid, convert(char(10),DelDet.ReqDate,103) as ReqDate,Reg.name,Reg.street1,Reg.street2,Reg.pin,Reg.category,Reg.kit_type,Reg.alternate_phone from @table1 DelDet JOIN db_registration Reg on Reg.userid=DelDet.userid MadhivananFailing to plan is Planning to fail
Thank You. Its working now.What is i want the date in DD-MM-YYYY format.Do u have some link where all these codes like 103 are listed?www.JamboreeBliss.com |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-01 : 09:45:01
|
| Read about convert function in SQL Server help fileIt has example for all date formationsMadhivananFailing to plan is Planning to fail |
 |
|
|
bhanu2217
Starting Member
35 Posts |
Posted - 2009-12-01 : 23:50:44
|
quote: Originally posted by madhivanan Read about convert function in SQL Server help fileIt has example for all date formationsMadhivananFailing to plan is Planning to fail
Thank you.www.JamboreeBliss.com |
 |
|
|
|
|
|
|
|