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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Evaluate datfield with NOW() 1

Status
Not open for further replies.

malaygal

IS-IT--Management
Feb 22, 2006
192
US
I have need to display some records on my asp page from my Access database where a datefiled (general date format) is greater than now().
This sql below does not seem to work

strsql = "SELECT * from tblLock where lockdate > " Now()

Any help will be greatly appreciated.
 
Code:
strsql = "SELECT * from tblLock  where lockdate > " [!]&[/!] Now()
 
it wouldn't work at all and will give an error when you run that code.

the SQL sent to the server would be
Code:
SELECT * from tblLock  where lockdate >


maybe you missed off the ... > [blue]&[/blue] Now()




Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Shouldn't that be...

[tt][blue]
strsql = "SELECT * from tblLock where lockdate > [!]#[/!]" & Now() & "[!]#[/!]"
[/blue][/tt]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks for all the replies.

George, your string works.

So that I do not have to open another thread, and this is in line with date formatting:

I have an input field on my asp page with mm/ddyyy (and time) format. User can either select date from a calendar picker , leave the default value from db or blank it out.
On my update (db) page, I evaluate the value of this field as:

country = trim(Request("country"&iLoop))
version = trim(Request("version"&iLoop))
schedule = trim(Request("schedule"&iLoop))
lockdate = trim(Request("lockdate"&iLoop))

if lockdate = "" then
strsql = "UPDATE tblLock SET lockdate = null & _
" WHERE version = '" & version & "' and schedule = '" & schedule & "' and country = '" & country & "'"
else
strsql = "UPDATE tblLock SET lockdate = '" & lockdate & _
"' WHERE version = '" & version & "' and schedule = '" & schedule & "' and country = '" & country & "'"
end if

My page breaks when user blank-out the input date field.

Appreciate any assistance.
 
It looks like you are missing a quote.

Code:
      if lockdate = "" then
               strsql = "UPDATE tblLock  SET lockdate = null [!]" [/!]& _
                        " WHERE version = '" & version & "' and schedule = '" & schedule & "' and country = '" & country & "'"
      else
               strsql = "UPDATE tblLock  SET lockdate = '" & lockdate & _
                        "'  WHERE version = '" & version & "' and schedule = '" & schedule & "' and country = '" & country & "'"
      end if

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top