Click here to Skip to main content
15,916,188 members
Home / Discussions / Database
   

Database

 
AnswerRe: INT and VARCHAR Pin
Sathesh Sakthivel12-Jun-07 2:07
Sathesh Sakthivel12-Jun-07 2:07 
QuestionHow to Customized SQL Report Viewer Control Pin
Ali Raza Shah11-Jun-07 18:38
Ali Raza Shah11-Jun-07 18:38 
QuestionPervasive SQL 8.0 Pin
Soleil couchant11-Jun-07 17:00
Soleil couchant11-Jun-07 17:00 
AnswerRe: Pervasive SQL 8.0 Pin
Sathesh Sakthivel11-Jun-07 18:51
Sathesh Sakthivel11-Jun-07 18:51 
GeneralRe: Pervasive SQL 8.0 Pin
Soleil couchant11-Jun-07 19:14
Soleil couchant11-Jun-07 19:14 
QuestionExecute SSIS package Pin
alexfromto11-Jun-07 11:02
alexfromto11-Jun-07 11:02 
AnswerRe: Execute SSIS package Pin
Sathesh Sakthivel11-Jun-07 16:11
Sathesh Sakthivel11-Jun-07 16:11 
QuestionTransforming and verifying dates Pin
~~~Johnny~~~11-Jun-07 9:09
~~~Johnny~~~11-Jun-07 9:09 
I am probabely be called an idiot rom now on but I can't figure this out, tried everything. Here I have to trasfer in SQL a very disfunctionnal FMP database. This is the function that verifies the dates. The problem I have is this:

It works perfectly when the original date (formatted 01/01/1800) is correct but the last part should overwrite any malformed date (anyways that was the intention....) but none get overwritten. I always get the malformed date back. It is as if @DateTest never gets put to False. Help!!Confused | :confused:


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER FUNCTION [dbo].[GetBirthDate]
(
@BirthDate nvarchar(10)
)
RETURNS nvarchar(10)
AS
BEGIN

DECLARE @ReturnValue nvarchar(10)
DECLARE @DateTest bit
SET @DateTest = 'True'

IF (@BirthDate = '00/00/00' OR @BirthDate = '' OR @BirthDate = '?' OR @BirthDate IS NULL)

SET @ReturnValue = '1800-01-01'

ELSE

BEGIN

IF LEN(@BirthDate) = 10

SET @ReturnValue = SUBSTRING(@BirthDate, 7, 4) + '-' + SUBSTRING(@BirthDate, 4, 2) + '-' + LEFT(@BirthDate, 2)

ELSE

SET @ReturnValue = '19' + SUBSTRING(@BirthDate, 7, 2) + '-' + SUBSTRING(@BirthDate, 4, 2) + '-' + LEFT(@BirthDate, 2)

END

IF (SUBSTRING(@ReturnValue, 1, 2) <> '19' AND SUBSTRING(@ReturnValue, 1, 2) <> '20') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 3, 1) < '0' OR SUBSTRING(@ReturnValue, 3, 2) > '9') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 4, 1) < '0' OR SUBSTRING(@ReturnValue, 4, 2) > '9') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 6, 1) < '0' OR SUBSTRING(@ReturnValue, 6, 2) > '1') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 7, 1) < '0' OR SUBSTRING(@ReturnValue, 7, 2) > '9') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 9, 1) < '0' OR SUBSTRING(@ReturnValue, 9, 2) > '3') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 10, 1) < '0' OR SUBSTRING(@ReturnValue, 10, 2) > '9') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 5, 1) <> '-') SET @DateTest = 'False'
IF (SUBSTRING(@ReturnValue, 8, 1) <> '-') SET @DateTest = 'False'

IF @DateTest = 'False' SET @ReturnValue = '1800-01-01'

RETURN @ReturnValue

END
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
AnswerRe: Transforming and verifying dates Pin
~~~Johnny~~~11-Jun-07 9:39
~~~Johnny~~~11-Jun-07 9:39 
Questionuniqueidentifier data type Pin
Brendan Vogt11-Jun-07 8:52
Brendan Vogt11-Jun-07 8:52 
AnswerRe: uniqueidentifier data type Pin
Michael Potter11-Jun-07 8:59
Michael Potter11-Jun-07 8:59 
AnswerRe: uniqueidentifier data type Pin
Jhonny Alejandro Galeano Calle13-Jun-11 5:58
Jhonny Alejandro Galeano Calle13-Jun-11 5:58 
QuestionSystem.Data.SQlClient.SQlException [modified] Pin
Vimalsoft(Pty) Ltd11-Jun-07 4:26
professionalVimalsoft(Pty) Ltd11-Jun-07 4:26 
AnswerRe: System.Data.SQlClient.SQlException Pin
originSH11-Jun-07 4:53
originSH11-Jun-07 4:53 
GeneralRe: System.Data.SQlClient.SQlException Pin
Vimalsoft(Pty) Ltd11-Jun-07 20:29
professionalVimalsoft(Pty) Ltd11-Jun-07 20:29 
QuestionOracle DBF export Pin
Vertyg011-Jun-07 2:40
Vertyg011-Jun-07 2:40 
AnswerRe: Oracle DBF export Pin
andyharman11-Jun-07 6:24
professionalandyharman11-Jun-07 6:24 
GeneralRe: Oracle DBF export Pin
Vertyg011-Jun-07 7:21
Vertyg011-Jun-07 7:21 
GeneralRe: Oracle DBF export Pin
andyharman11-Jun-07 23:06
professionalandyharman11-Jun-07 23:06 
GeneralRe: Oracle DBF export Pin
RussellT5-Jun-09 9:17
professionalRussellT5-Jun-09 9:17 
QuestionAny work arounds for getting rid of Process Blocking in SQL2000 Pin
Jayaraman B10-Jun-07 23:37
Jayaraman B10-Jun-07 23:37 
AnswerRe: Any work arounds for getting rid of Process Blocking in SQL2000 Pin
andyharman10-Jun-07 23:55
professionalandyharman10-Jun-07 23:55 
Question[Message Deleted] Pin
Brendan Vogt10-Jun-07 22:31
Brendan Vogt10-Jun-07 22:31 
AnswerRe: SELECT Not Working Pin
SimulationofSai10-Jun-07 22:49
SimulationofSai10-Jun-07 22:49 
AnswerRe: SELECT Not Working Pin
Harini N K10-Jun-07 22:49
Harini N K10-Jun-07 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.