Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 12th, 2004, 07:54 PM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default Date Problem

Hi All,

I am try to add the current date into my access database. I only want dd/mm/yyyy so i format my date like this.

Code:
' Format Date
    showDate = DatePart("d", Now()) & "/" & DatePart("m", Now()) & "/" & DatePart("yyyy", Now())


It enters the date as 30/12/1899 which must be a default date.

The funny thing is that when i output showDate on the screen it displays correctly but not when adding to the DB.

I have also check that it is a valid date.

Any suggestions.

Thanks Tim

TDA
__________________
TDA
Reply With Quote
  #2 (permalink)  
Old August 12th, 2004, 08:27 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Mentiri, Muara, Brunei.
Posts: 363
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello TDA,

  Check your system date whether it is correct or not. Or

showDate=day(date) & "/" & month(date) & "/" & year(date)



Reply With Quote
  #3 (permalink)  
Old August 12th, 2004, 08:38 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

It is wise to enter dates into the database as yyyy/mm/dd.
This way the database will get it right. (at least MSSQL,ACCESS,MSDE)


======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #4 (permalink)  
Old August 12th, 2004, 09:06 PM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default

Hi,

My system time is correct, ive tried all combinations and also tried asigning the database field as Date and Now() and the only difference when i go yyyy/mm/dd is that it gives me 18/1/1900

Any ideas what im doing wrong.

TDA
Reply With Quote
  #5 (permalink)  
Old August 12th, 2004, 09:13 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What DB are you using?
Can you post the entire SQL statement that is being sent to the DB?
Check your regional settings are set to Australia.


======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #6 (permalink)  
Old August 12th, 2004, 09:41 PM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default

Yes my regional settings are set to Australia. dd/mm/yyyy

Im using MS Access2000 and my datatype for DeedDate is Date/Time (Medium)

Here is my code

' Format Date
showDate=day(date) & "/" & month(date) & "/" & year(date)

' enable opportunity
strUpdate = "UPDATE Registrations SET DeedStatus = " & 1 & ", DeedDate = "& showDate &" WHERE RegistrationID = " & ID
        objConn.Execute(strUpdate)

No matter how i change the format of the showDate or put in Date or Now() directly into the SQL it doesn't work.

thanks Tim


TDA
Reply With Quote
  #7 (permalink)  
Old August 12th, 2004, 09:47 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Tim,

You will need to enclose the date in single quotes.

Code:
DeedDate = '"& showDate &"' WHERE
This will fix the problem but I still recommend using yyyy/mm/dd for the format when putting into the database.

CARN' THE DOCKERS



======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #8 (permalink)  
Old August 12th, 2004, 09:50 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Actually MS ACCESS may require a hash, try both

DeedDate = #"& showDate &"# WHERE

But I think it should be ok through ODBC.

ANY ACCESS GURU's out there may confirm.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #9 (permalink)  
Old August 12th, 2004, 10:01 PM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default

Thanks Rod,

It worked! DAM THOSE SINGLE QUOTES

I have taken your advice about formatting dates yyyy/mm/dd

BTH: I tested both ways and you can use the # aswell, but from memory mssql chucks the sads if you use #

Thanks again mate

Tim :)

TDA
Reply With Quote
  #10 (permalink)  
Old August 12th, 2004, 10:07 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

No worries, anytime.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
DATE PROBLEM ricespn Classic ASP Basics 3 October 20th, 2006 07:15 AM
Date Problem kuku SQL Server 2000 4 September 7th, 2005 08:38 PM
Date Problem. rupen Classic ASP Basics 3 June 3rd, 2005 09:58 AM
date problem hosefo81 PHP How-To 2 May 26th, 2004 11:12 AM
Date problem Larson VB How-To 2 December 30th, 2003 05:10 PM



All times are GMT -4. The time now is 02:48 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.