- air
- ajax
- algorithm
- apple
- bitbucket
- braintapper_exchange
- charts
- chumby
- codeigniter
- cognos
- complexity
- crashplan
- crosstab
- dash
- dashboard
- date
- dbvisualizer
- decisions
- dimension
- dogfood
- dona_wong
- dropbox
- edward_tufte
- extension
- feature_checklists
- feature_excellence
- filemaker
- firefox
- firewall
- flot
- flowing_data
- fogbugz
- football
- free
- freenas
- freshbooks
- git
- github
- gm
- google_charts
- iPad
- javascript
- jdbc
- jedox
- mac
- macbook
- maps
- marsedit
- mercurial
- metaweblog
- metrics
- microstrategy
- monowall
- moo
- nathan_yau
- news
- nosql
- open_source
- palo
- pentaho
- pfsense
- printing
- programmers_interfaces
- rapidweaver
- regex
- regexr
- rest
- safari
- smoothwall
- sony
- sqlpower
- stackoverflow
- statistics
- stephen_few
- svg
- tablet
- ticket_agent
- time_machine
- tip
- tm1
- transformer
- trick
- typographic grid
- usability
- visualization
- vmware
- w3c
- web
- wiki
- wikkawiki
- work_management
- wsj
November 18, 2009
Whether you're working in Cognos, Pentaho or some other BI tool, you'll inevitably be given a data element with a date format your system doesn't like.
Usually it involves a month abbreviation and having to convert it to a number.
Not all formula languages provide this type of conversion with a built-in command.
The first solution that usually comes to mind is an
There is a quicker way to do this, using the string location function in your tool of choice, which of course, is never the same between tools.
Here's a quick version in pseudocode:
Let's walk through my pseudocode.
FIND is the command that I want to use for searching my string, and here's the syntax: FIND(needle;HAYSTACK)
It should return me with the first position of the string when found. In some formula languages, it's substr or substring.
Gotcha: Some FIND commands are indexed at 1, others at 0. That means the first character could return 0 or 1. I'm going to assume that FIND returns 0. If your FIND command returns 1, you'll have to adjust accordingly.
So let's look at the string positions:
A couple of things worthy of note. I've indexed with zero, and I've left-padded my string with hashes (#). Because of how my pseudocode FIND works, searching for "JAN" will return 3, since that's the first character position it finds. "FEB" will return 6, "MAR" will return 9 and so on.
Since each of these results are divisible by 3, all I need to do is return the position divided by 3 to give me the month number. If your FIND command is indexed with 1, then the string positions would look like this:
You should only pad your haystack string with 2 hashes in this case.
So to recap, perform an uppercase conversion on your abbreviation in case your FIND command is case sensitive, and divide the "found" position by 3.
Easy peasy.
Usually it involves a month abbreviation and having to convert it to a number.
Not all formula languages provide this type of conversion with a built-in command.
The first solution that usually comes to mind is an
if->elseif or case / switch block to handle the month abbreviation conversion.There is a quicker way to do this, using the string location function in your tool of choice, which of course, is never the same between tools.
Here's a quick version in pseudocode:
FIND(UCASE("Jan");"###JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"))/3Let's walk through my pseudocode.
FIND is the command that I want to use for searching my string, and here's the syntax: FIND(needle;HAYSTACK)
It should return me with the first position of the string when found. In some formula languages, it's substr or substring.
Gotcha: Some FIND commands are indexed at 1, others at 0. That means the first character could return 0 or 1. I'm going to assume that FIND returns 0. If your FIND command returns 1, you'll have to adjust accordingly.
So let's look at the string positions:
###JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC012345678901234567890123456789012345678A couple of things worthy of note. I've indexed with zero, and I've left-padded my string with hashes (#). Because of how my pseudocode FIND works, searching for "JAN" will return 3, since that's the first character position it finds. "FEB" will return 6, "MAR" will return 9 and so on.
Since each of these results are divisible by 3, all I need to do is return the position divided by 3 to give me the month number. If your FIND command is indexed with 1, then the string positions would look like this:
##JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC12345678901234567890123456789012345678You should only pad your haystack string with 2 hashes in this case.
So to recap, perform an uppercase conversion on your abbreviation in case your FIND command is case sensitive, and divide the "found" position by 3.
Easy peasy.
