Re: Converting Number to Date

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Don wrote:

It seems from my research that I cannot simply use an expression to convert a
date such as 20060831 in an excel file from a number to a date format in
Access without first converting the number to a string then breaking out the
different componenets of the date Year, Month and Day then somehow
recombining them back into one field and somehow formatting them to a date
format. If so I need some help.

My thought is, for each componenet, to do something like this:

1) Make a query that imports all of the fields needed for my table and three
additional fields that include 3 seperate expressions using Left, Mid and
Right breaking out each componenent of the date (Year, Month and Day). Not
sure how to convert numbers to strings.

Putting these three fields back together is also foggy. Questions I have are:

"RequestDate" is the name of the field in my Access table and "Request Date"
is the name of the field in my Excel file.

A) Do I create another query to join the three fields making a new
RequestDate field?
B) If so in the query, how do I put them together? Concastenate?
C) Once converted to string, how do I change the format to Date?


Just use a calculated field in the query that does the
import:

RequestDate: CDate("#" & Left([Request Date],4) & "-" &
Mid([Request Date],5,2) & "-" & Right([Request Date],2) &
"#")

--
Marsh
MVP [MS Access]
.



Relevant Pages

  • RE: Payroll Query
    ... I have tested both functions and the query against some dummy data, ... Yes the text column is in the format hh:mm and no there are no null values, ... function to return it as a Date/Time data type provided that that no value ... Public Function TimeSumAs String ...
    (microsoft.public.access.queries)
  • Re: DCOUNT format question
    ... > When I enter your string into the control on the form, ... >> Yes, your format is incorrect. ... >>>I can get this to work in a totals query but not on a form. ... >>> initials ...
    (microsoft.public.access.forms)
  • RE: Payroll Query
    ... I missed the from clause from the query: ... Yes the text column is in the format hh:mm and no there are no null values, ... function to return it as a Date/Time data type provided that that no value ... Public Function TimeSumAs String ...
    (microsoft.public.access.queries)
  • Re: Access not accepting functions in queries
    ... Simon, change the last line of your query statement to: ... Judging from your Format() expression, you wanted the date only, so use Date. ... Assuming that your Date field is a Date/Time type, you have now asked JET to match a date against a string. ...
    (microsoft.public.access.queries)
  • Re: Converting Number to Date
    ... Access without first converting the number to a string then breaking out ... recombining them back into one field and somehow formatting them to a date ... format. ...
    (microsoft.public.access.formscoding)