Reply
How to update sql 2005 record with today's date from asp
Old 01-26-2008, 01:51 PM How to update sql 2005 record with today's date from asp
Super Talker

Posts: 107
Hey all,

I've been searching for hours and I can't find the answer.

I need to update existing records with today's date through ASP into a SQL 2005 Express table

If I do the following on via opening a recordset...

strSpotlightQ = "update artistspotlight set displayDate2 = '1/26/2008'"

rsSpotlight.Open strSpotlightQ

It works. The field "displayDate2" is a date field in the SQL table, but it also works on "displayDate" which is a character.

My problem is that I want my ASP program to determine what the date is.

strSpotlightQ = "update artistspotlight set displayDate2 = " & date()

It won't work. This sounds dumb, but even if I put quotes around it it won't work. Even if I use cdate(date()) it doesn't work.

Can anyone please tell me how the heck to update the date in SQL 2005 through ASP?

This is mighty important.

Thanks
DonnaZ
DonnaZ is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 01-26-2008, 06:46 PM Re: How to update sql 2005 record with today's date from asp
chrishirst's Avatar
Super Moderator

Posts: 11,894
Location: Blackpool. UK
use single quotes for dates in MS Sql

column = '" & date() & "' ;"

or use the SQL date function

... column= date() ;"

or a convert()

column = CONVERT(datetime," & date() & ") ;"
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-27-2008, 10:02 PM Re: How to update sql 2005 record with today's date from asp
Banned

Posts: 59
Name: Amir Mullick
Location: USA, New York---Born in India
Use single dates. Its not so hard mate.
Amirmullick3 is offline
Reply With Quote
View Public Profile Visit Amirmullick3's homepage!
 
Old 01-28-2008, 02:53 AM Re: How to update sql 2005 record with today's date from asp
chrishirst's Avatar
Super Moderator

Posts: 11,894
Location: Blackpool. UK
Quote:
Originally Posted by Amirmullick3 View Post
Use single dates.
And that means?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-28-2008, 07:37 PM Re: How to update sql 2005 record with today's date from asp
itHighway's Avatar
Average Talker

Posts: 24
Name: Zeeshan Dar
Location: GUJ
Quote:
Originally Posted by chrishirst View Post
use single quotes for dates in MS Sql
column = '" & date() & "' ;"
or use the SQL date function
... column= date() ;"
or a convert()
column = CONVERT(datetime," & date() & ") ;"
Donnaz,

Sql date function Or Convert function should work. Make sure to remove semicolon from query.
__________________
Zeeshan Dar
itHighway - web design development custom e-commerce solution & web based real estate listing software services provider

Last edited by itHighway : 01-28-2008 at 07:38 PM.
itHighway is offline
Reply With Quote
View Public Profile
 
Old 01-29-2008, 03:13 AM Re: How to update sql 2005 record with today's date from asp
chrishirst's Avatar
Super Moderator

Posts: 11,894
Location: Blackpool. UK
Quote:
Make sure to remove semicolon from query
Why would you do this?

or rather

Why do you think semicolons should be removed?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-29-2008, 07:01 PM Re: How to update sql 2005 record with today's date from asp
Learning Newbie's Avatar
Moderator

Latest Blog Post:
What Does This Look Like?
Posts: 4,737
Name: John Alexander
Update Table Set Column = GetDate()

Or

Update Table Set Column = GetUtcDate()


Also, are you really trying to open a result set from an update query?
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is online now
Reply With Quote
View Public Profile
 
Old 02-04-2008, 07:43 AM Re: How to update sql 2005 record with today's date from asp
Novice Talker

Posts: 5
does NOW() not work? i could be wrong

Matt
mattmoo is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to update sql 2005 record with today's date from asp
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14601 seconds with 13 queries