Ask Your Question
2

I want to form a union query in Access, but the format of a field is altered by the query.

asked 2022-01-25 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-12-24 02:00:00 +0000

djk gravatar image

To avoid altering the format of a field in a union query in Access, you can use the CAST function to convert the data type of the field to the desired format.

For example, if you have two tables with a "Date" field, where one table stores dates as text in the format "mm/dd/yyyy" and the other as actual dates, you can use the following union query to combine the data without altering the format:

SELECT Date FROM Table1 UNION ALL SELECT CAST(Date AS TEXT) FROM Table2

In this example, the second select statement converts the date field from Table2 to text using the CAST function, and preserves the original format.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-25 11:00:00 +0000

Seen: 9 times

Last updated: Dec 24 '21