SQL Query from Access to SQL Server

Hi

I'm trying to convert an SQL Query from Access to SQL Server. The
Access Query goes like this:

SELECT Format(EntryDate, 'ddd mm dd') AS [Day]
FROM JournalEntries

This query returns the name of the day followed by month and date (Su
aug 21)

What would this be like in SQL Server ? What style id do I have to use
to get the correct format ?


Regards
Rune
Rune [ Di, 25 September 2007 12:00 ] [ ID #1828689 ]

Re: SQL Query from Access to SQL Server

(rune [at] totalweb.no) writes:
> I'm trying to convert an SQL Query from Access to SQL Server. The
> Access Query goes like this:
>
> SELECT Format(EntryDate, 'ddd mm dd') AS [Day]
> FROM JournalEntries
>
> This query returns the name of the day followed by month and date (Su
> aug 21)
>
> What would this be like in SQL Server ? What style id do I have to use
> to get the correct format ?

select convert(varchar(11), EntryDate)

For more options on date formatting, look up the topic on Cast and Convert
in Books Online.

The best is to return the date a datetime value to the client, and let
the client do the formatting.


--
Erland Sommarskog, SQL Server MVP, esquel [at] sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx
Erland Sommarskog [ Di, 25 September 2007 23:00 ] [ ID #1828704 ]
Datenbanken » comp.databases.ms-sqlserver » SQL Query from Access to SQL Server

Vorheriges Thema: Clustered index on the identity column or a datetime column
Nächstes Thema: autoincrement question sql 2005 server