Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Help with Concatenating date values in SQL


Message #1 by anne.do@c... on Thu, 26 Sep 2002 15:05:37
wrap your DatePart functions in CONVERT(varchar, DatePart(...)) functions, then it
should concatenate just fine with the '/' string.

hope this helps,

john

--- anne.do@c... wrote:
> Is there a way to format a date value from Access into 'M/D/YYYY' format 
> directly from the database.  I tried the query below but adding a + '/' + 
> in between doesn't work becuase datepart is a date type and the '/' is a 
> varchar type.  So it's giving me the error "Datatype mismatch".  Is there 
> a way to write is so that StartDate returns the format 'M/D/YYYY'?
> 
> SELECT LAST_NAME AS LastName, FIRST_NAME  AS FirstName , 
> (Datpart('m', START_DT) + '/' + DatePart ('d', START_DT) + '/' + DatePart
> ('yyyy',START_DT)) AS StartDate 
> FROM EMPLOY
> 
> 
> 
> Thank you,
> Anne Do
> anne.do@c...


=====

---------------------------- 
John Pirkey 
MCSD 
http://www.stlvbug.org


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

  Return to Index