Solved

Access Union Query - Inconsistent Date formatting

Posted on 2011-02-24
13
486 Views
Last Modified: 2012-05-11
Hi, I'm working with a union query that brings together 8 or so queries with all identical columns, separated for ease of user entry due to the volume of information in each.

I've formatted the date field in each query to Short Date.  The individual queries look perfect.  When they're viewed in the Union Query, some (seemingly random) rows also show the time alongside the date.  

Any suggestions as to why or how to fix?  Thanks.
0
Comment
Question by:cdarbonne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34969532
try using
 Datevalue([DateField])

instead of format
0
 

Author Comment

by:cdarbonne
ID: 34969592
Sorry to sound like an idiot - but where do I put that?  the format setting was in the properties dialog.  Is this added to the SQL in the Union Query?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34969621
<s this added to the SQL in the Union Query?> yes


select datevalue([dateField]) from table1
union all
select datevalue([dateField]) from table2

etc..
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:cdarbonne
ID: 34969701
Ok, here's how it looks.  I added the 'as' becuse it was naming it Exp0001.  I must still be doing something wrong becuase I get a "#Error" for some dates now

SELECT Diesel.[Product Family], Diesel.Status, Diesel.[Property/UUT], Diesel.[Test Type], Diesel.Fuel, datevalue (Diesel.[Planned/Actual SOT]) as [Planned/Actual SOT], Diesel.[ESpec CRD], Build_Schedule.[Property/UUT], Build_Schedule.[Customer MRD], Build_Schedule.[Revised Promise Date], Build_Schedule.BSS, Build_Schedule.BAS, Build_Schedule.[Build Location], Diesel.Modified, Diesel.[On HOLD?], ([Planned/Actual SOT]-[Revised Promise Date])/7 AS [PSOT-RPD DTime], (Round([PSOT-RPD DTime],1)) AS [Delta Time]
FROM Diesel LEFT JOIN Build_Schedule ON Diesel.[Property/UUT] = Build_Schedule.[Property/UUT]



Thanks again for the help
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34969737
check for NULL values on field [Planned/Actual SOT]


run a simple select query

select [Planned/Actual SOT], dateValue([Planned/Actual SOT])
from Diesel

then run this one

select [Planned/Actual SOT], dateValue([Planned/Actual SOT])
from Diesel
where [Planned/Actual SOT] <> Null
0
 

Author Comment

by:cdarbonne
ID: 34969787
Ok, did it.  Attaching results...

thanks. 1st one 2nd one
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34969807
do you want to SHOW the NULL values on field [Planned/Actual SOT] in your query?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34969825
i am also wondering, how come some records have Time values on field [Planned/Actual SOT].
do you know how this field [Planned/Actual SOT] got filled in or updated?
0
 

Author Comment

by:cdarbonne
ID: 34969850
No, I'm totally confused about that.  These tables are pulled into Access via Sharepoint.  They're linked tables.  The users enter their data in sharepoint and I pull it in to Access.  I double checked the date/time option in sharepoint and they're all set to date only.  I can't change the table formatting in Access (because Sharepoint is the boss) but I did change it in the query.  In all the queries, it looks great.  Except the union query.  That's where I'm having this issue.
0
 

Author Comment

by:cdarbonne
ID: 34969859
Oh and yes, I do want to show null values.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 34970017
you have to use this format, test this one

select [Planned/Actual SOT], IIF([Planned/Actual SOT]<> Null, dateValue([Planned/Actual SOT]),Null)  
from Diesel
0
 

Author Comment

by:cdarbonne
ID: 34970104
That works great!  Do I need to use "As" to create the properly named column?

Thank you
ee3.JPG
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34970121
<Do I need to use "As" to create the properly named column?> Yes you can.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question