lampbob
lampbob

Reputation: 781

Date Format - Change format of Month from String to Numeric Value

I would think this is relatively straight forward but cant find documentation on how to do it(or the correct syntax to use) and my messing around hasn't worked so far.

For Dates we have a custom format called Month /Day /Year. This pulls back a the date(as a date type) in date format as such:

"14 April 2003"

The code behind this is:

(DATEPART('year', [Close Date])*10000 + DATEPART('month', [Close Date])*100 + DATEPART('day', [Close Date]))

What I want to get back is the month is numeric format like:

"14.04.2003"

Is it simply changing the "month" part in the code to a different type? Has any one come across this?

Cheers

Upvotes: 0

Views: 11823

Answers (4)

lampbob
lampbob

Reputation: 781

Followed your advice and just had to change the date pill, in the column field, to a continuous value. Then right clicked -> format -> Scale -> custom. Then used the above suggested format setting. Thanks Petr, woodhead92.

Upvotes: 0

Petr Havlik
Petr Havlik

Reputation: 3317

lampbob, I'd just use date formatting which will mean you will still be able to use all the date-fields flexibility that Tableau provides.

Select Custom format with the following input:

dd.mm.yyyy

See the screen below for more details:

enter image description here

Upvotes: 2

woodhead92
woodhead92

Reputation: 127

This can be easily achieved using the 'Format' option in Tableau. Here are the steps to follow to format the date field as you have specified.

  1. Add Date field to your Rows/Columns field on a Tableau worksheet.
  2. Set the format of the Date to be DAY(Date).
  3. Click on options for 'DAY(Date)' and go to 'Format...'
  4. On the Format DAY(Date) panel, go to Scale -> Dates.
  5. Select 'Custom' option and type in 'mm.dd.yyyy'. Now the date will be in the string format you need.

Screenshots: String format for date, Changing to 'DAY' and 'Format...'

Upvotes: 1

Alex Blakemore
Alex Blakemore

Reputation: 11896

If you are only concerned about how the date is presented, then leave the datatype as a date, and use a custom format string via the format pane to display it as desired.

Upvotes: 0

Related Questions