SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Date Format Query


Date Format Query

Author
Message
sabyasm
sabyasm
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1094 Visits: 524
Dear All,

I am reading a flatfile on which few columns are of the type date.

Those columns contains valid date format for most of the rows : mm-dd-yyyy hh:nn:ss

However some of the rows contain various string to show that the information is not available - example "NA" - "[Not Available]" - "[Access Denied]" and so on...

I am using an derived column component to typecase the date formatted string into DT_DBTIMESTAMP and want to reject the records which is not of the form -- that is arbitary strings.

I am using the logic :

Check if the column contains ":" if yes - then it seems to be a valid date of the format mm-dd-yyyy hh:nn:ss -- else consider this to be a NULL date.


LEN([Password Last Set Time]) == 0 ? NULL(DT_DBTIMESTAMP) : ((FINDSTRING([Password Last Set Time],":",1) == 0) ? NULL(DT_DBTIMESTAMP) : (DT_DBTIMESTAMP)([Password Last Set Time]))


Please let me know if you feel this is the correct approach - or advise accordingly.

Your help is much appreciated.

--
Sabya

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search