This content has been marked as final. Show 7 replies
I have had major problems with dates as well. I think because were using the european format.
First, you don't need the createodbcddatetime in the cfparam, you have already done this above it.
I have tried setting the locale and all other thinks with no luck, so this is what I do now.
I make sure that the date can only be entered into the form field with a particular format (dd/mm/yyyy)
I check this both at the client and the server.
I then pull the form field apart in the createdatetime function, note I also do this if the time values are passed in the form as well.
Thanks for the prompt reply Ken.
However it does not work for me. Maybe I haven't explained it well.
When I code it as you have suggested, the isert statement will not insert the hh:mm:ss - and it will round the date up - so for example if I have 28/11/2006 23:59:59 it will round it up to 29/11/2006 in the field (note - no time). I do not want this - I want this to be exactly as I have specified it above. I have noticed that the now() function is entered in such format only if you do not use the cfqueryparam. It will not work in the same way with the above variable because it is a string (don't judge for having tried it - I am getting desperate).
Well I've found the problem.
I've been inserting a date and time which actually gets rounded up/down to the nearest 30 seconds. For example:
28/11/2006 23:59:59 would be rounded up to 29/11/2006 00:00:00 but the 00:00:00 would not show because frankly they are zero's (i.e. trailing zero’s).
I’ve noticed that if I put 28/11/2006 23:59:29 it will round it down to 28/11/2006 23:59:00
This way I am losing only one minute, which for my application, is not that drastic.
It seems like CF does not cater for precise times. I may be wrong but this is what I’ve found in my environment and if anyone knows better then please let me know.
I poked a bit further and I think the problem is not with CF - it is with MsSQL. It is MsSQL that rounds numbers up/down.
This seems to happen even with milliseconds - i.e. 999 is rounded up by 1 which has the 'reverse domino effect' on the date/time.
Not that I need it, but for curiosity sake, how does CF handle milliseconds? Or does it?
I have never had this problem, but I have not needed to use milliseconds either.
But the MS article indicates that this should only happen if the millisecond is 999.
Thus it should not round down as you have indicated.
What version of MS SQl Server and level of patch have you installed ?
After looking at the CF function for date/time it would appear that CF only goes to seconds.
I am running MsSQL 2k running on winXP Prof with Service Pack 2 on my local machine.
The same is installed on the server running win2k Server.
I don't think for the sake of the application that I am developing I need milliseconds, but I was getting curious. If I lose a minute for the closingDate then so be it. Maybe I will get back to it when I have a bit more time.
On another note, is there a way of getting the date given the week of the year? I want to find out the dates Monday to Friday given the week and the year.
Just a point to note.
If you installed winXP sp2 after you installed sql server 2k sp 4 then you will need to install sql server 2k sp 4 again.
On another note, is there a way of getting the date given the week of the year?
Yes, but off hand I could not tell you how.