Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What query can I create  to remove some characters from a field in Access

Posted on 2011-02-25
6
Medium Priority
?
249 Views
Last Modified: 2012-05-11
Hello,

I have a field in Access that has the time and date shown like this: 1/10/2011 10:14.  I would like to remove the time and only show the date.  What query can I create to accomplish this?
0
Comment
Question by:nblassen
[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
  • 2
  • 2
  • 2
6 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 34980630
If the data type is Date:


UPDATE [SomeTable]
SET [SomeColumn] = Int([SomeColumn])

Open in new window



If the data type is Text, and if the time is always at the end of the string:


UPDATE [SomeTable]
SET [SomeColumn] = Left([SomeColumn], InStrRev([SomeColumn], " ") - 1)

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34980724
just use datevalue()

update tablex
set [datefield]=datevalue([datefield])
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 34980849
Rey,

In this case, Int and DateValue will yield the same result.  I recommended Int instead of DateValue because, if I remember gustav correctly, DateValue is slow as molasses :)

Patrick
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:nblassen
ID: 34980885
To matthewspatrick:
I tried the expression but it said Syntax Error in query expression.
I'm a novice Access user, so can you give me more instruction.  Thanks!
0
 

Author Comment

by:nblassen
ID: 34980889
The data type is Text.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 34980906
try this

update tablex
set [datefield]=iif([datefield] is null, null,datevalue([datefield]))

or

update tablex
set [datefield]=iif([datefield] is null, "",datevalue([datefield]))
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

597 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