ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 31st, 2003, 03:58 PM
sasb2003 sasb2003 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: UK
Posts: 5 sasb2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
asp sql time format - simple question !?

Working in VBScript ASP page with MSAccess Db.

Well I'm darn embarrased for this to be my first post on here - you know when you've solved all the big stuff and then some tiny stupid little thing sends you flat opn your face ?

I want to put a time into my sql statement, like this :

INSERT INTO hoursTbl (opening,closing) VALUES ('09:15','17:35')

or

#09:15#,#17:35#

or

#9:15:00#,#17:35:00#

etc etc....

nearly all of them work if I run them in Access itself, but none are working in my ASP page. I get the standard 'syntax error in INSERT statement' error message

Is it a special syntax I need?

.. feeling dumb !

Regards

Reply With Quote
  #2  
Old November 2nd, 2003, 01:16 AM
LabRaTT's Avatar
LabRaTT LabRaTT is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Boston, MA, USA
Posts: 23 LabRaTT User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this works

i tested this on my sql server 2000 and it works

<%
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=database;uid=username;pwd=password"
objConn.Open

SQLString4 = "INSERT INTO hoursTbl (opening, closing)"
SQLString4 = SQLString4 & " VALUES ('09:15','17:35')"
objConn.execute(SQLString4)


objConn.Close
set objConn = Nothing
%>
hjhjhjhj

Reply With Quote
  #3  
Old November 2nd, 2003, 01:18 AM
LabRaTT's Avatar
LabRaTT LabRaTT is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Boston, MA, USA
Posts: 23 LabRaTT User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
also

here is a way you can format your times before you enter them into the database



<%
Private Function PMilTime(ByVal dtime)
Dim hr,mn
hr = Hour(dtime) : mn = Minute(dtime)
If Len(hr) = 1 Then hr = 0 & hr
If Len(mn) = 1 Then mn = 0 & mn
PMilTime = hr & ":" & mn
End Function

Response.Write PMilTime("1:15 pm")
Response.Write "<br>"
' returns 13:15
Response.Write PMilTime("1:15")
' returns 01:15
Response.Write "<br>"
Response.Write PMilTime("6:32 pm")
' returns 18:32
Response.Write "<br>"
Response.Write PMilTime("1:01")
' returns 01:01
%>

Reply With Quote
  #4  
Old November 3rd, 2003, 03:22 AM
sasb2003 sasb2003 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: UK
Posts: 5 sasb2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
red herring !

Cheers, works fine !

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > asp sql time format - simple question !?


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway