Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Date problem in database
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Date problem in database

 Post Reply Post Reply
Author
Anakin View Drop Down
Newbie
Newbie
Avatar

Joined: 27 January 2004
Location: Belgium
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Anakin Quote  Post ReplyReply Direct Link To This Post Topic: Date problem in database
    Posted: 27 January 2004 at 4:46am

Hi, I've got a problem with my database

I've got a couple of pages where you can insert dates into a database. Format: dd/mm/yyyy

Works great, if the day cannot be a month.

When I pick a day between the 1st and the 12th, the bigger number, whether it is the day, or the month, will become the month.

So 27/01/2004 will be inserted as 27/01/2004, but 03/02/2004 for instance, will be inserted as 02/03/2004

Even more strange, with these two dates, 03/02/2004 will be known as *before* 27/01/2004

 

I hope someone can help me with it.

 

 

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2004 at 6:18am

Dates are always tricky. Best thing is to have special dropdowns for days/month/year and let the user pick the dates from them. You grab then the values and insert them in the db. This way you make sure the months and days are not mistaken.

When you retrieve them from db, use the datePart function to make sure you have the correct values.

Cristian Banu
Soft 4 web
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2004 at 7:11am

At times I've had to disect the date from a known format then reassemble it again into a known format. Time is a bugger to work with as well, especially when you need a high degree of accuracy.

There was a question on something like this at sqlservercentral.com a couple weeks ago. It was about translating dates for a database that served UK and US offices.

Try setting your LCID explicitly. It might help out.

If you need some messy ugly horrible date processing code, let me know. I might have something that can help.

 

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2004 at 7:18am
Originally posted by Bluefrog Bluefrog wrote:

Try setting your LCID explicitly. It might help out.

Not all webhosters accepts other LCID than their own... I could not found a host to accept Romanian LCID (my case). So, this may not be the best solution. The only thing that realy helps is hard coding.

Cristian Banu
Soft 4 web
Back to Top
Anakin View Drop Down
Newbie
Newbie
Avatar

Joined: 27 January 2004
Location: Belgium
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Anakin Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2004 at 10:29am

@ zaboss: If nothing else helps, I'll try that way, with the dropdowns. I'd prefer having it another way, but that might be the best solution.

@ Bluefrog: I've tried it with LCID. The problem is, it helps with getting the dates out of the database, but it's no good for inserting anything in it.
For the moment, when typing the date in the US-format in the administration panel, it goes into the database like that, and thanks to LCID, where users can see it, it shows in Belgian-format.

So, if anyone knows how I can make it so that I can insert anything in a format other than the host's default, it would be greatly apreciated.

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2004 at 10:38am

You could use:

outputdate =  DatePart("yyyy", RS("mydatefield")) &"-"& DatePart("m", RS("mydatefield")) &"-"&DatePart("d", RS("mydatefield"))

insertdate = ""& DatePart("yyyy", Request.Form("MyInputForm")) &"-"& DatePart("m", Request.Form("MyInputForm")) &"-"& DatePart("d", Request.Form("MyInputForm")) &""

I use this as I need to have my dates mySQL compliant since I design apps that work with Access/SQL Server/MySQL, and mySQL is the most problematic with dates. It inserts and retrieve the dates in yyyy-mm-dd format, but, of course, you could adjust it to suit your needs.

Cristian Banu
Soft 4 web
Back to Top
Anakin View Drop Down
Newbie
Newbie
Avatar

Joined: 27 January 2004
Location: Belgium
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Anakin Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2004 at 8:57am

I'll see if this can help me

But thanks for the help

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.