PC Review


Reply
Thread Tools Rate Thread

Convert and sort date originally formated as text

 
 
Cagney
Guest
Posts: n/a
 
      24th Jan 2011
I have a text file that i import and it has a field contaning dates in
the format DDMMMYY as a text string. I would like to convert it to a
date that Access can sort properly. Can anyone offer some help.
Thanks.
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      24th Jan 2011
On Mon, 24 Jan 2011 06:20:29 -0800 (PST), Cagney <(E-Mail Removed)> wrote:

>I have a text file that i import and it has a field contaning dates in
>the format DDMMMYY as a text string. I would like to convert it to a
>date that Access can sort properly. Can anyone offer some help.
>Thanks.


Sure. Open the table in design view and add a new field, specifying Date/Time
as its datatype. Then run an Update query updating this field to:

CDate(Format([yourtextdate], "@@-@@@-@@"))

This will format the 24JAN11 to 24-JAN-11, which CDate can translate to a
date/time field.

Note that a date/time value is actually stored as a Double Float number, a
count of days and fractions of a day since midnight, December 30, 1899; it can
be formatted any which way, sorted chronologically, etc.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
Cagney
Guest
Posts: n/a
 
      24th Jan 2011
On Jan 24, 9:20*am, Cagney <hatma...@gmail.com> wrote:
> I have a text file that i import and it has a field contaning dates in
> the format DDMMMYY as a text string. I would like to convert it to a
> date that Access can sort properly. Can anyone offer some help.
> Thanks.


Thanks very much to each of you.
Both your options worked like a charm.
Gratefull for your quick responses.
Have a nice day!
 
Reply With Quote
 
David-W-Fenton
Guest
Posts: n/a
 
      25th Jan 2011
John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:(E-Mail Removed):

> Note that a date/time value is actually stored as a Double Float
> number, a count of days and fractions of a day since midnight,
> December 30, 1899; it can be formatted any which way, sorted
> chronologically, etc.


I've found it useful recently to use the term "string representation
of dates," which is what the formats are. The raw numeric
representation is hard to see, unless you use the "General Number"
format to display it in its raw form.

All the other formats that are human-friendly are string
representations of the underlying date values and when doing
calculations, need to be converted back to the underlying numeric
value. Given that there are so many ways to format the string
representation, and then different ways to interpret it (e.g.,
3/2/2010 is either in February or March, depending on the
interpretation), it's important to realize that whenever you are
doing calculations or writing criteria for a SQL WHERE clause, you
need to use either an unambiguous string representation of the date,
or use a precise date value (using DateSerial() or CDate()).

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
 
Reply With Quote
 
 
 
Reply

Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date formated as text Karen53 Microsoft Excel Programming 2 18th Jun 2008 08:32 AM
How do I convert a number formated as a date to text in Excel? =?Utf-8?B?QnJvdGhlck5vdg==?= Microsoft Excel Misc 5 2nd Mar 2005 03:51 PM
text is automatically formated as date! Emski27 Microsoft Excel Misc 1 6th Aug 2004 09:40 PM
Re: sort (on part of) string - originally posted under Tricky Sort Tom Ogilvy Microsoft Excel Programming 0 6th Aug 2004 02:42 AM
convert a date and then sort it =?Utf-8?B?Q2hyaXM=?= Microsoft Access Form Coding 4 14th Jun 2004 01:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:36 AM.