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 |
alxtech
Yak Posting Veteran
66 Posts |
Posted - 2006-03-09 : 14:55:01
|
Hello forum:I am selecting a date field from an oracle database, that table field is of datatype timestamp(6). which means date is store as date including miliseconds, example 20-JUN-03 04.55.14.000000 PM.I need to cast this field to date, which i did as:cast(event_date as date) and got a return 06/20/03 4:55 pm, Question:I program need to get this date as 06/20/03 no time included.I can't find a way to remove the time from date.i use trunc function but did not workThank you |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-03-09 : 15:21:08
|
You can use CONVERT with a style to get rid of the time. However, this type of formatting should be done at the presentation layer and not in T-SQL. It should only be done in T-SQL if you are formatting the data for a file.SELECT CONVERT(varchar(10), GETDATE(), 101)Tara Kizeraka tduggan |
|
|
alxtech
Yak Posting Veteran
66 Posts |
Posted - 2006-03-09 : 15:34:43
|
this is my current code:In database EVENT_DATE IS OF THE TYPE TIMESTAMP(6)Set recordSet = dbConn.Execute("SELECT EVENT_NAME,CATEGORY,cast(EVENT_DATE AS DATE) FROM table_name WHERE cast(EVENT_DATE AS DATE) = '" & mDate & "'")mDate has to be: MM/DD/YYYY no timeotherwise application won't work. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-10 : 03:55:52
|
Select date without conversion. In your Front end application, use the format like format(date,"mm/dd/yyyy"). Also if you are using Oracle and not SQL Server, then post your question at DBforums.comMadhivananFailing to plan is Planning to fail |
|
|
|
|
|