Hey Everyone,
I am just starting to learn T-SQL and came across something that puzzled me when looking at dates.
If I enter this:
SELECT CONVERT(datetime, CONVERT(varchar, GETDATE(), 101)) AS Expr1
In Enterprise Manager I get this output
12/30/2002 - which is what I assumed that I should get
In Query Analyzer I get this output
2002-12-30 00:00:00.000 - which I did not expect
Does anyone know why there would be a difference and if so, how do I get Query Analyzer to format as 12/31/2002?
Thanks alot,
BrentTry only: SELECT CONVERT(varchar, GETDATE(), 101) AS Expr1|||The style parameter is used when converting to a character type from a datetime - so when you converted it back to a datetime in query analyzer it showed you what you asked for. This is the true format - em will jack with the format but the reality is different. em will see all zeroes for time as no time and only displays slashes (no dashes).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment