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

adding dates/times to access

Status
Not open for further replies.

Cullen411

Programmer
Aug 17, 2005
89
GB
This is a function that I created to insert dates and times into an Access database in this format "YYYY-MM-DD HH:MM:SS"
It seems to work fine.
Can anyone see any difficulties with the function causing problems on a UK or US server?

<%
Function AccessDateTime (str)
Dim aDay
Dim aMonth
Dim aYear
Dim aTime

aDay = Day(str)
aMonth = Month(str)
aYear = Year(str)
aTime = Time()

AccessDateTime = aYear & "-" & aMonth & "-" & aDay & " " & aTime
End Function


dim connection
dim sSQL, sConnString

sSQL="INSERT INTO tblDate (dDate) VALUES (#" & AccessDateTime(NOW()) & "#)"

sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("datedb.mdb")

Set connection = Server.CreateObject("ADODB.Connection")

connection.Open(sConnString)
connection.execute(sSQL)

Connection.Close
Set Connection = Nothing
%>
 
Couple of follow up questions

Is the format YYYY-MM-DD HH:MM:SS the same is SQL Server, and with both Access and SQL Server should there be a space in the format?

One other thing are the variables below strings?

aDay = Day(str)
aMonth = Month(str)
aYear = Year(str)
aTime = Time()

thanks
 

Check out faq222-2244 for forum guidelines, and some ideas on basic research.

aDay = Day(str) ****** Integer
aMonth = Month(str) ****** Integer
aYear = Year(str) ****** Integer
aTime = Time() ****** DateTime

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I guess I violated the mulitple questions with the follow ups. sorry about that.
 
Cullen411
...and the basic research
...and the acknowledgements
[smile]

onpnt
There are some amazing similarities between those 2 faqs[lol]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top