|
-
June 20th, 2001, 03:54 PM
#1
T-SQL
I am trying to trim or truncate a Date within my SQL 7 database to get rid of the Timestamp associated with it. The current format is - mm/dd/yyyy hh:mm:ss
I want it to look like - mm/dd/yyyy
Any suggestions?
-
June 21st, 2001, 12:58 AM
#2
Re: T-SQL
If you mean in the database itself, that isn't possible, cause their is no difference between date and time, it's all datetime. If you really want to get rid of it, you can convert it to a string, but then you lose all the advantages of the date data type. Or you can do both, just create a computed column that holds the value as a string in a given format.
If you just need to format it (like say for a report or query), there are several functions available. I think in this case you should use the convert function, which allows you to temporary convert it to a varchar with a given format (you should check out the SQL books online for more information on this function.)
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
June 21st, 2001, 03:30 AM
#3
Re: T-SQL
The Convert keyword in SQL server/Sybase can be used e.g.
Select Convert(VarChar(8),Timestamp,112) From TUSERS
--Timestamp is of datatypoe DATETIME
HTH,
D.
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
-
June 21st, 2001, 07:14 AM
#4
Re: T-SQL
If you are using this string in VB thenb you can format the string
Format(MyDate,"mm/dd/yyyy")
Iouri Boutchkine
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|