View Full Version : Help desperately required re: date formatting
russell298997
05-01-2009, 09:45 AM
Can anyone shed any light here before I abandon DataAssist.......
Pretty well every time i insert records using DataAssist it has been impossible to force a UK date format - either using <%Session.LCID=2057%> or switch function code recommended by WebAssist.
WebAssist support now concede that DataAssist can't insert the date in UK format (tho it has been known to do it correctly on some insert page, for some even more baffling reason) and say there is a bug and it may get fixed at some point in the future, but that's obviously not helping me now, knee deep in a project.
I have tried re-building a basic Dreamweaver Insert page and the date inserts fine. However I also need to use Dig File Pro to upload files WA engineer thought that should be fine) . Having added that, and changed all the "Request.Form" instances to "UploadFormRequest", I am left with the page falling over at the line using "If (CStr(UploadFormRequest("MM_insert")) = "form1") Then".
It brings up the same "can't call binary read" error message. If I change that instance of "Request" to "UploadFormRequest", I get an type mismatch error.
Can anyone shed any light on a way forward? I really have to be able to input dates in consistent UK format and be able to upload files from the same page. I'm not good enough write it all without extensions
Am I asking the technically impossible or does anyone know what needs to be changed in this code that's hanging. Or how to actually ensure a UK date format adhered to....
Would be very grateful for any suggestions.
Ray Borduin
05-01-2009, 10:37 AM
Validation Toolkit will reformat a date for you. What database type are you using? mySQL for instance only accepts Y-M-D H:M:S format.
Anybody from any region needs to use this format, not just UK, but US as well.
There are many functions and techniques for reformatting dates, but the right technique depends on your server language and database type.
russell298997
05-05-2009, 01:32 AM
Hi,
I'm using ASP and Access dBase, do you think Validation toolkit could do it?
Ray Borduin
05-05-2009, 03:26 PM
I'm pretty sure it could with client side validation and reformatting options. I'm not sure what format dBase expects, but you could probably look that up and make sure validation toolkit updates the date to the correct format.
russell298997
05-06-2009, 01:44 AM
thanks, that could be a life-saver. any pointers on how i would start applying the behaviour to change the date format around? i can see how the validator might flag up a date as being non-UK format but where/how would you instruct it to apply some change?
thanks for any assistance ray.
Ray Borduin
05-06-2009, 09:14 AM
Highlight the form and go to the Behaviors window in DW. Then apply the date validation behavior. It will ask the date format to use and you can set it in that interface. You can ignore the rest of the settings since all you care about is the date formatting.
russell298997
05-06-2009, 09:24 AM
ok. thanks
when i do there are two boxes - first one says "allow", second one says "reformat" - on the basis that i want people to input the date in dd/mm/yyyy format and the validator has to stop this being input as mm/dd/yyyy, what would you recommend i select as the settings for the two areas above?
Ray Borduin
05-06-2009, 09:29 AM
Well in some cases it isn't possible, since who knows what format 11/09/2009 is in after all, but I'd probably just do it onBlur instead of onSubmit. So instead of highlighting the form, highlight the form element itself and use the onblur even.
Set both start and end date formats to: dd/mm/yyyy
See if that works for you.
russell298997
05-06-2009, 09:44 AM
no, doesnt work (file attached) . i still get 02/07/2009 reversed to 07/02/2009. the other oddity is the subsequent email generated by universal mail with the vent info does show the date as correct tho.
any other bright ideas/hackrounds/thoughts..? other than that i have to abandon DataAssist which is a massive pity cos it helped me so much.
russell298997
05-06-2009, 09:46 AM
by the way, i quite take your point that "who knows what 02/11/2009 is" - i just dont want it automatically reversed - if you understand!
Ray Borduin
05-11-2009, 05:36 AM
So let me try to understand what you want... if the user enters:
4/3/2009 you would like it to set the date to 4/3/2009, but if they enter 3/30/2009 you would like to use 30/3/2009? is that correct?
What if someone types something that can't be resolved into a date like 21/20/2009? Or are you validating the form in some other way as well? Because of the different date standards, most forms will include a note like: (dd/mm/yyyy), and force people to use the correct format and validate and show an error message if the date is not in the correct format instead of trying to make guesses when the date seems wrong.
We can probably just figure out a simple script to account for the exact scenario you need. There won't be a need to abandon DataAssist because of this simple issue, it is just a matter of fixing the simple issue with what will amount to a few lines of code. No need to scap dozens of pages and hundreds of lines of code.
russell298997
05-11-2009, 05:56 AM
Hi,
Glad to hear you reckon it can be fixed. Will save me a trul massive amount of reworking.
To clarify then (and let's use an example of 1st May 2009 - or 01/05/2009 as I would want it):
My form does have a note that users should enter dd/mm/yyyy. i.e. 01/05.2009.
i quite appreciate that if someone mistakely enters 05/01/2009 that that's a valid date and no amount of validation would throw it up as incorrect, as opposed to someone entering 21/20/009, which i can validate out ok. if they put in 05/01/2009 that's a user error and that's that....
but currently, users are entering 01/05/2009 and getting 05/01/2009 written to the dBase - and then not on all pages for some reason. this date issue is made more acute since the records inserted are college events and Univ Mail is set up to auto-email them to relevant parties. so not only will administrators not know date's been reversed until they go to the detail page after inserting, an email is also going out with an incorrect date on it. (or at least it would if it wered all live - and it has to go live next week one way or the other)
all i want is that when someone enters 01/05/2009, that's what get's written to the dBase - that DataAssist inserts ands renders faithfully the date as it has been input
and that that's what shows on other pages. and that it's consistent across all instance thereof. if someone puts in mm/dd/yyyy despite being told otherwise, that's their problem!
(tho that's highly unlikely).
hope that clarifies things - and thanks for your continued assistance in getting this to some satisfactory conclusion Ray.
Ray Borduin
05-11-2009, 08:47 AM
It sounds like you need some help debugging and figuring out when this happens exactly. Once we can consistantly reproduce it, we should be able to find a fix pretty quickly.
If you can reproduce the problem, please post a support incident with your contact information. Then update this forum with your incident number. I'll try contacting you directly to find a solution.
russell298997
05-11-2009, 09:02 AM
Thanks.
I have successfully replaced some of the DAssist insert pages with the DWbasic insert behavior, amended the Request.Form instances to WA_DFP_UploadObj.Form and got these pages working with the date behaving ok. Obviously it semi-defeats the point of DataAssist tho! So, thanks for your offer, I'll post another ticket and maybe you can take a look in a Connect meeting ?
I have another DAssist insert page behaving incorrectly so maybe we can use that to compare/debug?
the new support incident is 93121
info321189
06-21-2009, 03:33 AM
Hi, if you use a mysql database you can format the date and time in the recordset with DATE_FORMAT (datefield, format) function.
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
Ray Borduin
06-22-2009, 06:30 AM
Please call me at the webassist office... extension 103 when you have a chance and I will show you how to get it to work with dataassist.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.