dbTalk Databases Forums  

Update query to detect textvalues and to change them into dates

comp.databases.ms-access comp.databases.ms-access


Discuss Update query to detect textvalues and to change them into dates in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
 
Posts: n/a

Default Update query to detect textvalues and to change them into dates - 09-06-2011 , 09:45 AM






In an import routine I have to deal with a table which holds, amongst
others, a text field in which most records have date values, except for
certain records where the field value is 'Unknown'. Before importing this
table into the master table, I'd like to change all possible text values in
this field to a dummy value '01-01-1900', so that the import routine doesn't
skip these records as the particular field there is of type 'Date'. Can this
be done with an update query? What criteria would pick out the records with
text values in the particular field?

Thanks in advance,
Martin

Reply With Quote
  #2  
Old   
Phil
 
Posts: n/a

Default Re: Update query to detect textvalues and to change them into dates - 09-07-2011 , 06:36 PM






On 06/09/2011 15:45:21, wrote:
Quote:
In an import routine I have to deal with a table which holds, amongst
others, a text field in which most records have date values, except for
certain records where the field value is 'Unknown'. Before importing this
table into the master table, I'd like to change all possible text values
in this field to a dummy value '01-01-1900', so that the import routine
doesn't skip these records as the particular field there is of type
'Date'. Can this be done with an update query? What criteria would pick
out the records with text values in the particular field?

Thanks in advance,
Martin


If InDate is your text version of the date, and OutDate is the final version
of the date, try OutDate = IIf(InDate =
"Unknown",CDate("01/01/00"),CDate(InDate))

Check the results carefully as 03/04/11 may be imterpreted as 3rd of April or
4th of March,depending on the local date format.

Phil

Reply With Quote
  #3  
Old   
 
Posts: n/a

Default Re: Update query to detect textvalues and to change them into dates - 09-10-2011 , 08:14 AM



Thank you Phil. It works!

Martin

"Phil" schreef in bericht news:j48v5e$f45$1 (AT) speranza (DOT) aioe.org...

On 06/09/2011 15:45:21, wrote:
Quote:
In an import routine I have to deal with a table which holds, amongst
others, a text field in which most records have date values, except for
certain records where the field value is 'Unknown'. Before importing this
table into the master table, I'd like to change all possible text values
in this field to a dummy value '01-01-1900', so that the import routine
doesn't skip these records as the particular field there is of type
'Date'. Can this be done with an update query? What criteria would pick
out the records with text values in the particular field?

Thanks in advance,
Martin


If InDate is your text version of the date, and OutDate is the final version
of the date, try OutDate = IIf(InDate =
"Unknown",CDate("01/01/00"),CDate(InDate))

Check the results carefully as 03/04/11 may be imterpreted as 3rd of April
or
4th of March,depending on the local date format.

Phil

Reply With Quote
  #4  
Old   
milewskp
 
Posts: n/a

Default Re: Update query to detect textvalues and to change them into dates - 09-10-2011 , 10:48 AM



Hi Martin,
IIf(IsDate(InDate), InDate, #01-01-60#)
Note: I prefer #01-01-60#, since #01-01-00# could be interpreted as
01-01-2000.

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: Update query to detect textvalues and to change them into dates - 09-11-2011 , 08:30 AM



On 10/09/2011 16:48:43, milewskp wrote:
Quote:
Hi Martin,
IIf(IsDate(InDate), InDate, #01-01-60#)
Note: I prefer #01-01-60#, since #01-01-00# could be interpreted as
01-01-2000.

Whoops, sorry, I'm so old I forgot that we had already reached the 21st
century. I should have suggested
OutDate = IIf(InDate "Unknown",CDate("01/01/1900"),CDate(InDate))
as otherwise "Unknown gets interpreted as 01/01/2000

Were the 3rd April & 4th March type dates OK?

Phil

Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.