chimchillas chimchillas - 26 days ago 5
SQL Question

Dates Being sent to SQL in many different formats, how do i handle this?

I I'm busy with editing my stored procedures for Reports i created a while back.
I encountered a problem where the parameters being sent to the stored procedures comes in all kinds of funky formats from multiple computers.

Some of the formats i have encountered has been

'2017-01-31'

'2017-31-01'

'01-01-2017'

'31012017'

'20170131'

I desperately need a way to handle all these different formats.
the '31012017' gives me a input error so it doesnt even want to reach my Converter so i made the input parameter a VARCHAR(15) to take all kinds of inputs.

Answer

The best possible fix i found was the following(works for almost all formats)

https://i.stack.imgur.com/MLARE.png

This way it picks up which format whatever PC you are using is using and sends a standardized format to SQL