Subject | RE: [firebird-support] How do I convert a timestamp to a string from within a stored procedure? |
---|---|
Author | Svein Erling Tysvær |
Post date | 2012-01-26T14:19:07Z |
Hi Michael!
You didn't ask, but there are a couple of things in your procedure that makes me wonder whether it is actually what you want (sorted in order of importance):
Set
You didn't ask, but there are a couple of things in your procedure that makes me wonder whether it is actually what you want (sorted in order of importance):
> ELSE IF ((iHour > 0) AND (iHour < 11)) THENProbably you want iHour < 10 rather than 11?
> sHour = '0' || iHour;
> IF (iHour > 12) THENThis basically means that you will be unable to differentiate between AM and PM and you cannot tell which of two timestamps come first (don't you care whether one entry is 6am or 6pm?).
> iHour = (iHour-12);
> STR_TIMESTAMP = sMonth || sDay || sYear || sHour || sMinute || sSecond;This will work OK as long as your application is local and you'll never have to sort or search depending on STR_TIMESTAMP. Internationally, several countries generally use DMY rather than MDY format, and if you avoid both of these and use YMD format, you also get a format that is easy to use for sorting and searching (well, not if you use a 12 hour clock).
Set