Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsDate troubles

Status
Not open for further replies.

nzgirl

Programmer
Feb 26, 2003
72
0
0
NZ
Man I'm loving the dates in my code.
Issue 1: I'm in New Zealand and we format our dates dd/mm/yyyy
Issue 2: IsDate doesn't seem to work!

Issue 1: faq333-3194 shows me how to set the locale... so I set it for NZ and that displays 28/03/2004 but when I try to enter that as a date it :
Microsoft OLE DB Provider for SQL Server error '80040e07'
Syntax error converting datetime from character string.

Issue 2:
my code looks like:
case "save":
if not IsDate(SendDate) then errMsg = errMsg & &quot;Please enter a valid Date format.<br> Either 8 Mar(ch) 2003 or 03/08/2003. <br>&quot;

if I type in 'asdasdhk' it sends the error msg correctly but
if I type in 28/03/2003 (a valid format here) the browser errors with
Microsoft OLE DB Provider for SQL Server error '80040e07'
Syntax error converting datetime from character string.

I guess this is correct as it thinks I'm trying to enter the 3rd of 28thMonth... but is there a way I can get it to error nicely?

But I thought that setting my locale would help ?

I want to be able to enter dates as 28 march 2003, 28/03/2003 and march 28 2003. I don't really want to be setting the date manually to dd/mm/yyyy as this app is going to be used in the states as well.. I can deal with changing the locale in a page but not manually fooling with the dates and ending up with 3/4/5 different verisons

And Ideas?
Thanks
 
looks like a SQL Server error. try calling
SET DATEFORMAT dmy to tell sql server to expect the day first.
 
One way i've gotten around this (i'm in aus - i feel your pain) before is after the date is input, convert it in code to &quot;dd/mmm/yyyy&quot; before using it. A date in the format 1/Jan/2004 is very hard for SQL to swap around on you :)

Transcend
[gorgeous]
 
Thanks for your replies.
I was banned from doing anything to the database .. so I ended up
doing an IsDate(SendDate) To pick up chars and 30th Febs
then
sday = day(SendDate)
smonth = month(SendDate)
if Len(SendDay)=1 Then SendDay = &quot;0&quot; & SendDay
if Len(SendMonth)=1 Then SendMonth = &quot;0&quot; & SendMonth
SendDate = Year(SendDate) & &quot;/&quot; & SendMonth & &quot;/&quot; & SendDay
before I insert into the database..
not as clean as I wanted...
but it works :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top