Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 27th, 2012, 12:06 PM
SFDonovan's Avatar
SFDonovan SFDonovan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Location: Texas
Posts: 350 SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level)SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level)SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 14 h 45 m 42 sec
Reputation Power: 6
Facebook
Masking Birthday with to_char(to_date(

I need to make everybody's birthday default to dd/mm/'1900' so that they are masked.

I can't seem to find the right combination.

Code:
UPDATE table a
SET a.BIRTHDATE = (
 SELECT to_char(to_date(b.BIRTHDATE,'dd/mm/yyyy'),'dd/mm' || '/1900')
  FROM table b


or

Code:
UPDATE table a
SET a.BIRTHDATE = (
SELECT nvl(to_date(to_char(b.BIRTHDATE
,'MM/DD') || '/1900')
, NULL)
FROM table b


I get error
ORA-01840: input value not long enough for date format



Any help is appreciated.

Reply With Quote
  #2  
Old April 27th, 2012, 02:13 PM
LKBrwn_DBA's Avatar
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2006
Posts: 752 LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 3 h 5 m 12 sec
Reputation Power: 348
Try this:
Code:
UPDATE tablea a
   SET a.birthdate =
          (SELECT TO_DATE ( TO_CHAR ( b.birthdate, 'dd/mm') || '/1900', 'dd/mm/yyyy')
             FROM tableb b)

__________________

Reply With Quote
  #3  
Old April 27th, 2012, 02:25 PM
SFDonovan's Avatar
SFDonovan SFDonovan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Location: Texas
Posts: 350 SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level)SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level)SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 14 h 45 m 42 sec
Reputation Power: 6
Facebook
Quote:
Originally Posted by LKBrwn_DBA
Try this:
Code:
UPDATE tablea a
   SET a.birthdate =
          (SELECT TO_DATE ( TO_CHAR ( b.birthdate, 'dd/mm') || '/1900', 'dd/mm/yyyy')
             FROM tableb b)



hmmmm

ORA-01839: date not valid for month specified


Here is an example

10/08/1982 00:00:00

Reply With Quote
  #4  
Old April 29th, 2012, 08:09 PM
clivew clivew is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 2,045 clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 37 m
Reputation Power: 382
I do not know if it helps but (no database involved):
This works for me.
Code:
begin
  -- Test statements here
  dbms_output.put_line('start: ');
  dbms_output.put_line(TO_DATE( TO_CHAR ( to_date('10-AUG-1951'), 'dd/mm') || '/1921', 'dd/mm/yyyy'));
  dbms_output.put_line('date: ');
end;


Output was

start:
10-AUG-21
date:

Are you sure all your source dates are valid?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Masking Birthday with to_char(to_date(

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap