cancel
Showing results for 
Search instead for 
Did you mean: 

Decoding a Date String

paul_cardinale
Trusted Enthusiast

Decoding a Date String

Message contains an image Message contains an attachment

I want to decode date strings from a variety of different formats.  Of course not all date strings are unambiguous; but I want to handle a reasonable range of possibilities.

Here's what I've come up with:

dds.png

Suggestions appreciated.

"If you weren't supposed to push it, it wouldn't be a button."
13 REPLIES 13
santo_13
Proven Zealot

Re: Decoding a Date String

This poses a new risk, many dates match more than one format, for example, 7/4/06 - this could be 7 Apr 2006 or 4 July 2006 or 6 Apr 2007 based on the user's location

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
GerdW
Knight of NI

Re: Decoding a Date String

Hi Paul,

 

you forgot:

  • dd.mm.yy(yy) (or mm.dd.yy(yy)) formats using points as separators
  • dd. %b yy(yy) format (you might get into trouble with foreign language month names)
  • ISO8601 formatted timestamps…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
BertMcMahan
Trusted Enthusiast

Re: Decoding a Date String

I've seen YYYYMMDD before too (just one long string), which would just be %<%Y%m%d>T.

paul_cardinale
Trusted Enthusiast

Re: Decoding a Date String


@GerdW wrote:

Hi Paul,

 

you forgot:

  • dd.mm.yy(yy) (or mm.dd.yy(yy)) formats using points as separators
  • dd. %b yy(yy) format (you might get into trouble with foreign language month names)
  • ISO8601 formatted timestamps…

I don't want to encourage anyone to use dotted formats (for dates and phone numbers).

 

"If you weren't supposed to push it, it wouldn't be a button."
paul_cardinale
Trusted Enthusiast

Re: Decoding a Date String

Message contains an image Message contains an attachment

New version

dds.png

"If you weren't supposed to push it, it wouldn't be a button."
GerdW
Knight of NI

Re: Decoding a Date String

Hi Paul,

 


@paul_cardinale wrote:
I don't want to encourage anyone to use dotted formats (for dates and phone numbers).

But exactly those are standard in Central Europe! (Well, atleast for dates. Never seen phone numbers using dots.)

Tomorrow is 08.07.2022 for me…

 

With a big grin: when asking a worldwide forum for opinions you should not reject worldwide suggestions because of an US point of view…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Frozen
Active Participant

Re: Decoding a Date String

Message contains an image

@GerdW wrote:

Hi Paul,

 


@paul_cardinale wrote:
I don't want to encourage anyone to use dotted formats (for dates and phone numbers).

But exactly those are standard in Central Europe! (Well, atleast for dates. Never seen phone numbers using dots.)

Tomorrow is 08.07.2022 for me…

 

With a big grin: when asking a worldwide forum for opinions you should not reject worldwide suggestions because of an US point of view…


Frozen_0-1657220975039.png

 

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
crossrulz
Knight of NI

Re: Decoding a Date String

Message contains an image

@Frozen wrote:

@GerdW wrote:

Hi Paul,

 


@paul_cardinale wrote:
I don't want to encourage anyone to use dotted formats (for dates and phone numbers).

But exactly those are standard in Central Europe! (Well, atleast for dates. Never seen phone numbers using dots.)

Tomorrow is 08.07.2022 for me…

 

With a big grin: when asking a worldwide forum for opinions you should not reject worldwide suggestions because of an US point of view…


Frozen_0-1657220975039.png

 


NOTE: The following comment is entirely tongue-in-cheek

Yeah, but as an American, I feel obliged to not care

 

On a more serious note, I do prefer YYYY-MM-DD because it makes sorting a lot easier.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
GerdW
Knight of NI

Re: Decoding a Date String

Hi,

 


@crossrulz wrote:

On a more serious note, I do prefer YYYY-MM-DD because it makes sorting a lot easier.


Me too!

(There's a reason why I mentioned ISO8601 in message #3…)

 


@crossrulz wrote:
Yeah, but as an American, I feel obliged to not care

Yes, I know.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019