Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

convert MONDAY, SEPTEMBER 21, 1942 to Datetime

Posted on 2008-10-12
2
Medium Priority
?
333 Views
Last Modified: 2013-11-30
I have a data file I am trying to convert into either a SQL Server or  Postgres database.  How can I convert the following date field value into a string compatible with either a Postgres or SQL Server date field?

MONDAY, SEPTEMBER 21, 1942

I will give points for either a way in Postgres or SQL Server.  Preferrably in T-SQL or pl/pg SQL
0
Comment
Question by:FreightTrain
2 Comments
 
LVL 3

Accepted Solution

by:
furrybootsistheanswer earned 2000 total points
ID: 22699557
Is your date as string currently? If so, you can use charindex and substring to remove the leading 'DAYNAME, '  and then simply convert to datetime. In SQL server:

select convert(datetime,substring('MONDAY, SEPTEMBER 21, 1942',(charindex(',','MONDAY, SEPTEMBER 21, 1942') +2), (len('MONDAY, SEPTEMBER 21, 1942') -1)),101)

0
 

Author Closing Comment

by:FreightTrain
ID: 31505524
Yes, it is a string!  AWESOME!  Thank You!!!  
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question