If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Dates and Differences between Query Analyzer and Enterprise Manager

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-02, 16:49
brentb brentb is offline
Registered User
 
Join Date: Dec 2002
Location: Denver
Posts: 2
Dates and Differences between Query Analyzer and Enterprise Manager

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,
Brent
Reply With Quote
  #2 (permalink)  
Old 12-31-02, 08:05
Steve_LL Steve_LL is offline
Registered User
 
Join Date: Dec 2002
Location: London, Ontario - Canada
Posts: 3
Re: Dates and Differences between Query Analyzer and Enterprise Manager

Try only: SELECT CONVERT(varchar, GETDATE(), 101) AS Expr1
Reply With Quote
  #3 (permalink)  
Old 01-06-03, 20:58
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
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).
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On