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, 10: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: 17
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, 12:04 PM
bzzz bzzz is offline
Registered User
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, 03: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: 17
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, 08:33 AM
bzzz bzzz is offline
Registered User
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 08:35 AM.

Reply With Quote
  #5  
Old May 11th, 2002, 12:48 PM
bzzz bzzz is offline
Registered User
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 12:52 PM.

Reply With Quote
  #6  
Old May 19th, 2002, 07: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: 17
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)


Developer Shed Advertisers and Affiliates


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

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap