Prev: Concatenating with and/or without a comma
Next: Query prompt one column for multiple random values
From: Tyro on 4 Mar 2010 16:50 This isn't exactly a Microsoft Access question, but I didn't know where else to go. I am using Microsoft SQL Server Management Studio. The table and field name are “dbo.EncounterData.CreateDateTime” The results are formatted like “2010-03-02 10:36:52.527”. Would you know how I can use the Convert function to format the results as “yyyymmdd”. I know it is something like one of these: select (convert (char(8), getdate(), 112) SELECT CONVERT(VARCHAR(8),CONVERT(DATETIME),112) but I can't get either one to work. -- Tyro from Missouri
From: Bob Barrows on 4 Mar 2010 20:31 Tyro wrote: > This isn't exactly a Microsoft Access question, but I didn't know > where else to go. I am using Microsoft SQL Server Management Studio. > The table and field name are "dbo.EncounterData.CreateDateTime" The > results are formatted like "2010-03-02 10:36:52.527". Would you > know how I can use the Convert function to format the results as > "yyyymmdd". I know it is something like one of these: > > select (convert (char(8), getdate(), 112) Why did you put the parenthesis before the name of the function? The general syntax for calling functions is functionname(parameters) Like this: select convert(char(8), getdate(), 112) > > SELECT CONVERT(VARCHAR(8),CONVERT(DATETIME),112) Ughh! ;-) The sql server version of this group is microsoft.public.sqlserver.programming -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
From: Tyro on 5 Mar 2010 09:44 Thank you Bob. -- Tyro from Missouri "Bob Barrows" wrote: > Tyro wrote: > > This isn't exactly a Microsoft Access question, but I didn't know > > where else to go. I am using Microsoft SQL Server Management Studio. > > The table and field name are "dbo.EncounterData.CreateDateTime" The > > results are formatted like "2010-03-02 10:36:52.527". Would you > > know how I can use the Convert function to format the results as > > "yyyymmdd". I know it is something like one of these: > > > > select (convert (char(8), getdate(), 112) > > Why did you put the parenthesis before the name of the function? The general > syntax for calling functions is > functionname(parameters) > Like this: > select convert(char(8), getdate(), 112) > > > > > SELECT CONVERT(VARCHAR(8),CONVERT(DATETIME),112) > > Ughh! ;-) > > The sql server version of this group is > microsoft.public.sqlserver.programming > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > . >
|
Pages: 1 Prev: Concatenating with and/or without a comma Next: Query prompt one column for multiple random values |