Ask Your Question
0

Query changes my date formatting

asked 2016-10-21 11:21:33 +0100

inasiopo gravatar image

Hi Everyone,

I am having a database (libreoffice 5.2 base) with a Date field. It is formatted as 31/12/2016. I then have a query where I want the date to show but with a different format. I want only the two last digits of the year.

I other words I want it to show as such...

table: 31/12/2016 -----> query: 16

I there a way to achieve that?

Many thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2016-10-21 11:49:50 +0100

Ciao, Use this code in query:

RIGHT( YEAR( "Date" ), 2 )

If my answer helped you, vote it with ✔ and with ∧ (here on the left)

edit flag offensive delete link more
0

answered 2016-10-21 16:31:04 +0100

pierre-yves samyn gravatar image

Hi

There is another way if you need to keep the field as a date:

  • Create a view instead of a query (same syntax)
  • Open the view, Right Click the date header▸Column Format▸update the format code, close the view.

The format is preserved (this manipulation is not preserved for queries) and the field is still a date. E.g. you can use DAY(DateField) in a query for instance.

Regards

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-10-21 11:21:33 +0100

Seen: 53 times

Last updated: Oct 21 '16