Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with validating date

Status
Not open for further replies.

kizziebutler

Programmer
Apr 28, 2005
81
0
0
GB
I am exporting a lot of data using BCP. I know that some of the fields that I am exporting are in the incorrect format or not valid date. I need to write a function or procedure to check against the date and put the correct date out in the correct format. Please could I ask assistance on this, I was looking at something like this:

CREATE function dbo.DateValid(@DateOut varchar(4), @DateIn char(3))
returns date
AS

BEGIN
declare@ret date getdate()
SET @ret = 0
IF (@Date LIKE 'YYYY/MM/DD HH:MM:SS' or
etc...
) AND
@PostcodeIn LIKE ' '
set@ret = Validdate
RETURN @ret
end
 
Strange I have been told isdate should work on char field but this is the reason I started this post, it doesn't return a validate.
 
ISDATE() does NOT return a valid date!!! It only tells you if a value or column you specify is valid.
 
Correct, jbenson001...Kizzie, I suggest you do less "talking" to people and more reading on this forum and the Books On Line, and trying to understand them. People have been saying use isdate, isdate, isdate, isdate, and in two threads you dismissed them all. That many people are not usually wrong. ;-)

Regards,
TJR
 
Furthermore, as you probably now see, you should use isdate() as a PART of your total solution, whether that solution be an UPDATE statement (see my post above), a function used in an update statement, etc.

Isdate() doesn't RETURN a valid date, it simply tells you when given a char field is that char field representative of a valid date/time or not (read the thread, it has been described in this way and shown in this way several times).

Please try to read, reread and understand, instead of responding with "NO, isdate doesn't work, how about THIS?"

TJR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top