If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > "Converting numbers into Dates"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-04, 19:42
lahary lahary is offline
Registered User
 
Join Date: Oct 2004
Posts: 4
"Converting numbers into Dates"

I'm working in Access 2000. I was given some tables with number (long integer) data types for dates, such as 20041011 for Oct. 11, 2004. How can I convert these rows of numbers into dates? in order to re-format the table to accept them as dates?

I prefer to do this within the sql statement (update query, etc). What is the sql syntax to do this? (assume the column name is Notdate). Thanks!!!
Reply With Quote
  #2 (permalink)  
Old 10-27-04, 03:34
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
For Access you can do it like this

Code:
UPDATE Tablename 
SET [NotDate] = DateSerial(Int(Left([notDate],4)),Int(Left(Right([NotDate],4),2)),INT(Right([NotDate],2)));
Reply With Quote
  #3 (permalink)  
Old 10-27-04, 04:04
DoktorBlue DoktorBlue is offline
Registered User
 
Join Date: Aug 2003
Location: Delft, The Netherlands (EU)
Posts: 447
It seems a better idea to me to create a second column D with datatype Date to store the result in:

UPDATE tablename SET D = DateSerial(...
__________________
Make everything as simple as possible, but not simpler! - A. Einstein
DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On