ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 10th, 2002, 11:26 AM
» Matt M « » Matt M « is offline
red house painter
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: South east England
Posts: 46 » Matt M « User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to » Matt M « Send a message via AIM to » Matt M «
null dates with asp3.0 (pulling out hair)

I want a quick piece of script which will test a date for an empty string, in which case post NULL but if there is a date, post the date which is within a variable.

it does one of the two, i.e if the date contains a date, i use formatdatetime,2 and its fine. the problem comes when i try to set a variable to null and post it in my insert statement, or on my editing page as an update statement.

how do i post a variable which contains null, to a date field in ms access?



matt

Reply With Quote
  #2  
Old May 10th, 2002, 01:04 PM
bzzz bzzz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 7 bzzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
'dateVar=date variable, may be empty string
'dateField is the name of the column in the table

sql="insert into " & tblName & " (dateField) Values ("
sql=sql & iif(dateVar<>"", dateVar ,"null")
sql=sql & ")"

Is that what you mean?

Reply With Quote
  #3  
Old May 11th, 2002, 04:36 AM
» Matt M « » Matt M « is offline
red house painter
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: South east England
Posts: 46 » Matt M « User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to » Matt M « Send a message via AIM to » Matt M «
would that work then?

i didnt know you could put if statements in sql statements.

ill try it out though

thanks

Reply With Quote
  #4  
Old May 11th, 2002, 09:33 AM
bzzz bzzz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 7 bzzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
no that iif is in the vbscript to build the sql statement

the sql statement is just a string so build it using standard vb string processing

actually iif may not be in vbscript - its in vb - you can either make your own iif or use an equivalent if then else. iif evaluates the first param, and if ithat's true it returns the second param else it return the third param

Last edited by bzzz : May 11th, 2002 at 09:35 AM.

Reply With Quote
  #5  
Old May 11th, 2002, 01:48 PM
bzzz bzzz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 7 bzzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
iif() is in vb but not vbscript. here's from my vbscript library

function iif(condition, trueval,falseval)
if condition then
iif=trueval
else
iif=falseval
end if
end function

Last edited by bzzz : May 11th, 2002 at 01:52 PM.

Reply With Quote
  #6  
Old May 19th, 2002, 08:54 AM
» Matt M « » Matt M « is offline
red house painter
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: South east England
Posts: 46 » Matt M « User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to » Matt M « Send a message via AIM to » Matt M «
i managed to get around the problem, by doing this:

if strRevDate > "" then
strRevDate = "'" & FormatDateTime(strRevDate,2) & "'"
else
strRevDate = "null"
end if

and then in the update statement:

Review_date = " & strRevDate & "

so, if its a date, the single quotes get posted and if not, they dont. this seems to work a treat (i did a lot of testing )

thanks for your advice, i just needed to use my brain a bit in the end.

matt

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > null dates with asp3.0 (pulling out hair)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
Stay green...Green IT