Date formula in Layout label

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Date formula in Layout label

Patrick Dunford-2

Good day

When I create a layout and put a text label in it I want to be able to show the current date using a formula. This formula can look something like [%format_date( $now,"yyyy-MM-dd HH:mm")%]

I have to put this in square brackets so that the formula is executed instead of it just appearing as plain text. However when displayed on the page, the square brackets are included in the output. How do I get rid of them so that I just have the numbers of the date and time displayed?


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Date formula in Layout label

Phil Wyatt

Hi Patrick,

 

Try changing the double quotes to single quotes and I think it should work (in QGIS3)

 

format_date( $now,'yyyy-MM-dd HH:mm')

 

Cheers - Phil

 

From: Qgis-user [mailto:[hidden email]] On Behalf Of Patrick Dunford
Sent: Monday, 10 June 2019 8:31 PM
To: qgis-user ML
Subject: [Qgis-user] Date formula in Layout label

 

Good day

When I create a layout and put a text label in it I want to be able to show the current date using a formula. This formula can look something like [%format_date( $now,"yyyy-MM-dd HH:mm")%]

I have to put this in square brackets so that the formula is executed instead of it just appearing as plain text. However when displayed on the page, the square brackets are included in the output. How do I get rid of them so that I just have the numbers of the date and time displayed?


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Date formula in Layout label

Patrick Dunford-2

It works, but it makes no sense

Anyway thanks

On 11/06/19 12:30 AM, Phil Wyatt wrote:

Hi Patrick,

 

Try changing the double quotes to single quotes and I think it should work (in QGIS3)

 

format_date( $now,'yyyy-MM-dd HH:mm')

 

Cheers - Phil

 

From: Qgis-user [[hidden email]] On Behalf Of Patrick Dunford
Sent: Monday, 10 June 2019 8:31 PM
To: qgis-user ML
Subject: [Qgis-user] Date formula in Layout label

 

Good day

When I create a layout and put a text label in it I want to be able to show the current date using a formula. This formula can look something like [%format_date( $now,"yyyy-MM-dd HH:mm")%]

I have to put this in square brackets so that the formula is executed instead of it just appearing as plain text. However when displayed on the page, the square brackets are included in the output. How do I get rid of them so that I just have the numbers of the date and time displayed?


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Date formula in Layout label

DelazJ
Hi,

Reading the help of the format_date function, the second argument should be a string, and I'm not sure that "yyyy-MM-dd HH:mm" is necessarily read as string in this context. I actually don't know what it's read as.

Le mar. 11 juin 2019 à 11:19, Patrick Dunford <[hidden email]> a écrit :

It works, but it makes no sense

Then please open an issue report if not yet done, to get it fixed.

Regards,
Harrissou

Anyway thanks

On 11/06/19 12:30 AM, Phil Wyatt wrote:

Hi Patrick,

 

Try changing the double quotes to single quotes and I think it should work (in QGIS3)

 

format_date( $now,'yyyy-MM-dd HH:mm')

 

Cheers - Phil

 

From: Qgis-user [[hidden email]] On Behalf Of Patrick Dunford
Sent: Monday, 10 June 2019 8:31 PM
To: qgis-user ML
Subject: [Qgis-user] Date formula in Layout label

 

Good day

When I create a layout and put a text label in it I want to be able to show the current date using a formula. This formula can look something like [%format_date( $now,"yyyy-MM-dd HH:mm")%]

I have to put this in square brackets so that the formula is executed instead of it just appearing as plain text. However when displayed on the page, the square brackets are included in the output. How do I get rid of them so that I just have the numbers of the date and time displayed?

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Date formula in Layout label

b.j.kobben

in these dialogs, double-quating is for variable (column) names, single quoting for strings (like most expression builders and eg. also in SQL)...

...and you are correct, this is not stated in any obvious place, that should be made more clear!

 

 

--

Barend Köbben

 

 

On 11/06/2019, 13:08, "Qgis-user on behalf of DelazJ" <[hidden email] on behalf of [hidden email]> wrote:

 

Hi,

 

Reading the help of the format_date function, the second argument should be a string, and I'm not sure that "yyyy-MM-dd HH:mm" is necessarily read as string in this context. I actually don't know what it's read as.

 

Le mar. 11 juin 2019 à 11:19, Patrick Dunford <[hidden email]> a écrit :

It works, but it makes no sense

Then please open an issue report if not yet done, to get it fixed.

 

Regards,

Harrissou

Anyway thanks

On 11/06/19 12:30 AM, Phil Wyatt wrote:

Hi Patrick,

 

Try changing the double quotes to single quotes and I think it should work (in QGIS3)

 

format_date( $now,'yyyy-MM-dd HH:mm')

 

Cheers - Phil

 

From: Qgis-user [[hidden email]] On Behalf Of Patrick Dunford
Sent: Monday, 10 June 2019 8:31 PM
To: qgis-user ML
Subject: [Qgis-user] Date formula in Layout label

 

Good day

When I create a layout and put a text label in it I want to be able to show the current date using a formula. This formula can look something like [%format_date( $now,"yyyy-MM-dd HH:mm")%]

I have to put this in square brackets so that the formula is executed instead of it just appearing as plain text. However when displayed on the page, the square brackets are included in the output. How do I get rid of them so that I just have the numbers of the date and time displayed?

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user