Dec 18
Jolle Carlestam Cool date converting
Dec 18, 2013; 20:24
Jolle Carlestam
Cool date converting
In the Lasso chat room there's right now a discussion on how to handle dates when retrieved from a mysql table.
Problem being that converting an input to a date object can be unpredictable depending on the type of value thats fed to the date type.
Some examples:
date(null)
date(string)
date(0.0)
->
01/01/0001 00:00:00
2013-12-18 20:15:57
1970-01-01 01:00:00
Three different dates returned, and none of them the desired outcome.
Yet all of the input values are possible and legitimate.
In the discussion, that's still ongoing, Kyle came up with a one row solution that would make sure that dates values indeed are converted to date objects and the rest will be converted to null.
define dateornull(n) => #n and date(#n) or null
Example usage:
dateornull(void)
dateornull(null)
dateornull('2013-12-18')
dateornull(1387389600.000000)
dateornull(void) -> type
dateornull(null) -> type
dateornull('2013-12-18') -> type
dateornull(1387389600.000000) -> type
->
2013-12-18
2013-12-18 19:00:00
null
null
date
date
Thus no more unexpected date values returned. If the input is not a value meant to be a date, null is returned. I all other cases a date object is returned.
Figured I'd share since not all of you hang in the chat room.
HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso
Lasso@lists.lassosoft.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Dec 19
Jussi Hirvi Re: Cool date converting
Dec 19, 2013; 23:04
Jussi Hirvi
Re: Cool date converting
Dec 19
Ke Carlton Re: Cool date converting
Dec 19, 2013; 21:24
Ke Carlton
Re: Cool date converting
Dec 19
Jussi Hirvi Re: Cool date converting
Dec 19, 2013; 23:34
Jussi Hirvi
Re: Cool date converting
Dec 20
Jussi Hirvi Re: Cool date converting
Dec 20, 2013; 00:03
Jussi Hirvi
Re: Cool date converting
Dec 19
Brad Lindsay Re: Cool date converting
Dec 19, 2013; 17:06
Brad Lindsay
Re: Cool date converting
Dec 19
Jolle Carlestam Re: Cool date converting
Dec 19, 2013; 23:05
Jolle Carlestam
Re: Cool date converting
Dec 19
Jolle Carlestam Re: Cool date converting
Dec 19, 2013; 23:18
Jolle Carlestam
Re: Cool date converting
Dec 20
Jussi Hirvi Re: Cool date converting
Dec 20, 2013; 11:26
Jussi Hirvi
Re: Cool date converting
Dec 20
Steve Piercy - Web Site Builder Re: Cool date converting
Dec 20, 2013; 02:32
Steve Piercy - Web Site Builder
Re: Cool date converting
Dec 20
Jussi Hirvi Re: Cool date converting
Dec 20, 2013; 12:45
Jussi Hirvi
Re: Cool date converting