Re: date format



On Tue, 20 Jun 2006 22:28:01 -0700, Tiffany wrote:

Hi,

I received a csv file which has a date column. The date format in this
column is 6-Mar (6 stands for 2006 which means Mar 2006). I will import this
data to an sql table and i want to date to look like 3/1/2006. Is it
possible. Kindly advise.

Thank you

Hi Tiffany,

If the format is always one numeric character, one dash, three letters
for the month (using stnadard English abbreviations), then try this
(changing the variable to your column name, of course)

DECLARE @TheDate char(5)
SET @TheDate = '6-Mar'
SELECT CONVERT(datetime, '1 ' + RIGHT(@TheDate, 3)
+ ' 200' + LEFT(@TheDate, 1))


--
Hugo Kornelis, SQL Server MVP
.



Relevant Pages

  • Re: CSV Date processing
    ... > Using the schema.ini file for a CSV file I need to ... All other data formats I can handle but ... > cannot get the SQL to handle the date format. ... > The file date values are in the format dd/mm/yy. ...
    (microsoft.public.vb.database)
  • CSV Date processing
    ... Using the schema.ini file for a CSV file I need to ... cannot get the SQL to handle the date format. ... The file date values are in the format dd/mm/yy. ... Does any-one have an example/syntax required to retrieve ...
    (microsoft.public.vb.database)
  • Re: Inserting regional settings specific data into sql server
    ... All EU countries withouth the two English speaking use the format dd-MM-yy ... By using the parameters, while the program is in the right culture setting, ... than all those formats results using SQLparameters in the way the SQL server ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Inserting regional settings specific data into sql server
    ... Italianyou will observe that the settings used are 10/02/2006 ... it a better idea to Format it using the string format functions or a very ... into the sql database.Sorry to bug the shorts off you but u now have context ... By using the parameters, while the program is in the right culture setting, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Moving a VBA function to SQL server
    ... SQL is a set-based language. ... "String Functions " in Books Online. ... This will produce a job header formatted like this: ... The format he specifies is stored in table 'Settings' - field 'JobHdrMask' ...
    (comp.databases.ms-access)